Hey again E.Pipo,
Sorry for the delayed response here! The free version doesn’t officially support select fields as of right now. It will likely do so in the future. In the meantime it might be possible with a PHP snippet. I will get back to you by the end of the week with an example.
– Craig
Thread Starter
Pipo
(@epipo)
Hi Craig,
No worries, thanks for your help! Awesome, I’ll wait for your snippet then, thanks a lot.
Etienne
Hey Etienne,
Here are the steps:
1) Create a custom field (“Custom 2” in this example)
2) Add this PHP to your functions.php for your theme:
function ru_custom_select( $field_attributes ) {
if ( isset( $field_attributes['custom2'] ) ) {
$field_attributes['custom2']['type'] = 'select';
$field_attributes['custom2']['meta'] = array( 'options' => array() );
// array ( LABEL, VALUE, IS PRESELECTED )
$field_attributes['custom2']['meta']['options'][] = array( 'First Option', 'First Option Value' , false );
$field_attributes['custom2']['meta']['options'][] = array( 'Second Option', 'Second Option Value' , false );
$field_attributes['custom2']['meta']['options'][] = array( 'Third Option', 'Third Option Value' , false );
}
return $field_attributes;
}
add_filter( 'rtec_fields_attributes', 'ru_custom_select', 10, 1 );
You can copy and paste the examples ($field_attributes[‘custom2’][‘meta’][‘options’][] = array( ‘First Option’, ‘First Option Value’ , false );) to create more options to select from as needed. If you are using a field other than “Custom 2” change “custom2” parts to match.
Let me know if you have more questions!
– Craig
Thread Starter
Pipo
(@epipo)
Hi Craig,
Thanks a lot, it works great! I didn’t see the rtec_fields_attributes
filter at the beginning. Extending this question, what about adding:
– A textarea?
– A hidden field?
Thanks again for your help!
-
This reply was modified 4 years, 3 months ago by
Pipo.
No problem!
No other field types are supported even with this filter at the moment. Possibly in the future though!
We are always trying to balance our Pro vs Free options (the Pro version offers these). I do think it makes sense to include all standard field types (radio, select, checkbox, textarea, number) in the future.
– Craig
Thread Starter
Pipo
(@epipo)
Ok, thanks for your answer. For sure this could make sense to include standard field types but I do understand the business logic behind it. I’ll have a look at the Pro version then.