Page 1 of 1

[ask]how to add class in selection (simbio_form_element.inc)

Posted: 06 Apr 2013, 05:44
by jushadi
./simbio2/simbio_GUI\form_maker/simbio_form_element.inc.php
[ask]how to add class in selection (simbio_form_element.inc)[question mark] :?:
if I make it like this

Code: Select all

$_buffer .= '<option value="'.$option[0].'" '.(($option[0] == $this->element_value)?'selected':'').' class="hadi'">'; 
I get class="hadi" for every selection list, but I want make it with selection option for array

for instance

Code: Select all

$mtype_options[] = array($mtype_data[0], $mtype_data[1]);
$form->addSelectList('memberTypeID', __('Membership Type').'*', $mtype_options, $rec_d['member_type_id']);
I want to make the third parameter in that array so it may look like this

Code: Select all

$mtype_options[] = array($mtype_data[0], $mtype_data[1],  $mtype_data[2]);
or like this

Code: Select all

$mtype_options[] = array('selection_value', 'selection_option', 'selection_class');
I get class for my selection with this code :oops:

Code: Select all

$_buffer .= '<option value="'.$option[0].'" '.(($option[0] == $this->element_value)?'selected':'').' class="'.$option[2].'">';
then initialize array option in form :arrow:

Code: Select all

$options[] = array('1', 'Mahasiswa', 'jus');
$options[] = array('2', 'Dosen', 'hadi');
$options[] = array('3', 'Pelajar', 'arman');
result : 8-)

Code: Select all

<select id="memberTypeID" name="memberTypeID">
<option class="jus" value="1">Mahasiswa</option>
<option class="hadi" value="2">Dosen</option>
<option class="arman" value="3">Pelajar</option>
</select>
but with this annoying errror : :?

Code: Select all

Notice: Undefined offset: 2 in simbio2/simbio_GUI/form_maker/simbio_form_element.inc.php on line 122
how to define array $option so it just not limit with 2 dimensional array, as default $option[0], and $option[1] working fine, but I get error undefined when I add the third parameter in array when initializing form with selection element, so $option[2] recognized as the third parameter, or is there any other way around to do this?

Re: [ask]how to add class in selection (simbio_form_element.

Posted: 07 Apr 2013, 15:47
by hqm
kalo pake array_fill / array_fill_key untuk pada saat inisialisasi?

*ini ceritanya mau ngapain sih mas? :D

Re: [ask]how to add class in selection (simbio_form_element.

Posted: 08 Apr 2013, 10:10
by jushadi
mau pakai plugin chain jquery, select list kedua harus memiliki kelas berbeda berdasarkan value pada select list pertama, solved tapi bukan pakai plugin chain

Re: [ask]how to add class in selection (simbio_form_element.

Posted: 11 Apr 2013, 16:39
by hqm
jushadi wrote:mau pakai plugin chain jquery, select list kedua harus memiliki kelas berbeda berdasarkan value pada select list pertama, solved tapi bukan pakai plugin chain
ooo pake apa pak? kali aja bisa dishare , buat belajar yang laen :D

Re: [ask]how to add class in selection (simbio_form_element.

Posted: 12 Apr 2013, 11:14
by jushadi
sekarang balik pakai chained jquery plugin lagi udah bisa, status solved

Re: [ask]how to add class in selection (simbio_form_element.

Posted: 18 Apr 2013, 11:42
by Annu
thanks jushadi for your help and kind consideration to make this possible