Adding a custom meta field with default NULL value which is not selectable
-
Good morning,
I’ve created some custom meta fields for job listings. One of those fields is a select field, where the user can select one option from a list. These are the functions which I used to add these fields.
add_filter( 'submit_job_form_fields', 'frontend_add_stageniveau_field' ); function frontend_add_stageniveau_field( $fields ) { $fields['job']['job_stageniveau'] = array( 'label' => __( 'Opleiding', 'job_manager' ), 'type' => 'select', 'required' => true, 'options' => array('MBO' => 'MBO', 'HBO' => 'HBO', 'Universiteit' => 'Universiteit', 'Anders' => 'Anders'), 'placeholder' => '', 'priority' => 7 ); return $fields; }
add_filter( 'job_manager_job_listing_data_fields', 'admin_add_stageniveau_field' ); function admin_add_stageniveau_field( $fields ) { $fields['_job_stageniveau'] = array( 'label' => __( 'Opleiding', 'job_manager' ), 'type' => 'select', 'options' => array('MBO' => 'MBO', 'HBO' => 'HBO', 'Universiteit' => 'Universiteit', 'Anders' => 'Anders'), 'placeholder' => '', 'description' => '' ); return $fields; }
After adding these functions the default value of the field ‘job_stageniveau’ is MBO, since this is the first value in the list. How can I make sure that the default value is NULL, but also make sure that it’s not possible for the user to save the form if the value of ‘job_stageniveau’ is still set to NULL.
Thanks in advance.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Adding a custom meta field with default NULL value which is not selectable’ is closed to new replies.