• Resolved gluehbirne

    (@gluehbirne)


    Hi,

    i need to make a field on job submission form only readable. is that possible and if yes, how is it possible?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support bindlegirl (a11n)

    (@bindlegirl)

    Hi there!

    In general, adding disabled to the input field will disable it (see here for details: https://www.w3schools.com/TAGS/att_input_disabled.asp).

    You could use that to create some custom code and disable the field you want.

    This tutorial for adding a custom field can help you figure out how to create the code:

    https://wpjobmanager.com/document/tutorial-adding-a-salary-field-for-jobs/

    Thread Starter gluehbirne

    (@gluehbirne)

    Hi @bindlegirl ,

    thanks for your answer. so – i found this tutorial,too. but i do not know how it helps, because i have got an existing field. can i add disabled or readonly property to an existing field?

    i found this snippet for example:

    // Add your own function to filter the fields
    add_filter( 'submit_job_form_fields', 'custom_submit_job_form_fields' );
    
    // This is your function which takes the fields, modifies them, and returns them
    // You can see the fields which can be changed here: https://github.com/mikejolley/WP-Job-Manager/blob/master/includes/forms/class-wp-job-manager-form-submit-job.php
    function custom_submit_job_form_fields( $fields ) {
    
        // Here we target one of the job fields (job_title) and change it's label
        $fields['job']['job_title']['label'] = "Custom Label";
    
        // And return the modified fields
        return $fields;
    }

    Is it possible to add disabled this way?

    • This reply was modified 3 years, 4 months ago by gluehbirne.
    Plugin Support bindlegirl (a11n)

    (@bindlegirl)

    Hey @gluehbirne

    We can’t help much with code customizations but I can suggest you take a look at the text-field.php template. You could override it with a custom version where, to use the code example from above, you could add something like this

    
    <?php if ( isset( $field['label'] ) == "Custom Label") { echo ' disabled'; } ?>

    You could add that right after the opening of the input tag.

    In that case, any field that has a label defined as “Custom Label” will be disabled.

    If you are not sure how to override template files, please check out this document:

    https://wpjobmanager.com/document/template-overrides/

    Hope this helps you figure out the next steps 😉

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘job submission form – make field only readable’ is closed to new replies.