⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

setRelation Dropdown option with attribute



farazu101

farazu101
  • profile picture
  • Member

Posted 22 March 2018 - 03:24 AM

$crud->set_table('m_values');
$crud->columns('attribute', 'value', 'position');
$crud->set_relation('attribute', 'm_attributes', 'name', array('status' => 'Active'), 'name asc');
 

 

<select id='field-attribute' name='attribute' class='chosen-select' data-placeholder='Select Attributes' style='width:300px'>

<option value=''></option>

<option value='1' >Red</option>

<option value='2' >Yellow</option>

<option value='3' >10 Units</option>

<option value='4' >20 Units</option>

</select>

 

I am getting an output as listed above. as Expected

 

Question

 

m_attributes table contains a column named 'type'

I wanted the data in column type during option is populated as class='type'

 

<select id='field-attribute' name='attribute' class='chosen-select' data-placeholder='Select Attributes' style='width:300px'>

<option value=''></option>

<option class='Color' value='1' >Red</option>

<option class='Color' value='2' >Yellow</option>

<option class='Dropdown' value='3' >10 Units</option>

<option class='Dropdown' value='4' >20 Units</option>

</select>

 

 

So based on the selected option class attribute, I need to hide 2 textbox below in the page