Home Forums Backend Issues (wp-admin) How to add a textarea to a field


How to add a textarea to a field

  • Hi there,
    I need to add a textarea to my fields (only the radio button fields but it could be on all fields), in the backend when editing a page.
    Then, I found this :
    It’s very easy to add it in the ACF form construction (where I don’t need it) but I wonder how to get it in pages. Because I need it to be filled by the users on every page for every field (in the backend).
    It takes place only in the backend, then I will display the values in the frontend.

    Thanks a lot for any help.

    add_action('acf/render_field_settings', 'my_remarque_render_field_settings');
    function my_remarque_render_field_settings( $field ) {
    	acf_render_field_setting( $field, array(
    		'label'			=> __('Remarque'),
    		'instructions'	=> __(''),
    		'name'			=> 'remarque',
    		'type'			=> 'true_false',
    		'ui'			=> 1,
    	), true);
    add_filter('acf/prepare_field/name=remarque', 'my_remarque_prepare_field');
    function my_remarque_prepare_field( $field ) {
    	if( $field['value'] == true ) {
    		// here I want to display a textarea in the page editing
  • If you want to add something additional to every field type that needs to be completed when completing the field, then no, this cannot be done. You would basically need to build a custom field type to replace every field type in ACF to add this additional value that needs to be entered. In the current field types ACF only saves the values that are needed for the fields. I think you should look at some other way to accomplish whatever it is that you’re doing.

  • Thank you for this answer.
    So, what you say is that I can’t achieve that without creating a new field type… that’s something I’m not able to do as I’m not developer.
    To get the idea, I want the user to choose a value in a list of choices and optionnaly add a comment. I need this comment to be linked to the field because the display will be not localised at the same place (so I need a reference).

  • If you’re using choice fields for the first part then you can use conditional logic to show a second comment field when any value is selected. There isn’t any way to “link” these fields except in the code you create. I don’t know of any way, given what you’ve described, to do this automatically.

  • Well it doesn’t make sense for me to have a conditional logic because I want to see this comment field always and for all choices fields.
    At this point, I don’t know how to achieve that but it’s a matter of time 😉

  • Basically, for each field you need to add a second field. I can’t say how you’d do what you want other than this since each ACF field can only hold one value.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘How to add a textarea to a field’ is closed to new replies.