• Resolved taufiqridha

    (@taufiqridha)


    Hai,
    i try to override required field on ‘wpforms_process_before’ that was set on editor. Try with this code

    function wpf_dev_process_before($entry, $form_data)
    {
    	if (absint($form_data['id']) !== 4115) {
    		return;
    	}
            // try to set some value to override required
    	$entry['fields'][18] = "sdff";
            //or also try to unset required , still not working
            unset($form_data['fields'][18]['required']);
    	return $entry;
    }
    add_action('wpforms_process_before', 'wpf_dev_process_before', 10, 2);

    but field id 18 still required when form sumbitted. Is there any way to override required fields that was set on editor?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hey @taufiqridha – Thanks for contacting us and I apologize for the delay in getting back to your support request!

    For the code that you’ve shared, I’ll have to check with the developers if it’s possible to override the required field. I’ll circle back with more information on this soon.

    Kindly,

    Hey @taufiqridha – Thanks for your patience!

    When you have some time, can you please share if is there any specific reason why you’re trying o override the required field? I just trying to get some context.

    Further, instead of overriding the required field, you can disable the required option and make your custom validation. Or, you can create a custom validation on top of the default validation. Here’s an example.

    Kindly,

    Thread Starter taufiqridha

    (@taufiqridha)

    Thanks for reaching out @prashantrai
    I already found the solution. But i’ll write here as reference to other. Or maybe you have more classy solution.

    So lets say i have 2 fields. All is required
    1. Radio button
    2. Text area

    I’ve created function in javascript to disable textarea if some value in radiobutton. But because of wpforms backend function check and found textarea are required and off course textarea on disable state, this will stop submission, and says textarea are required.

    In my case our Form are multiple form. I use beforepagechanged to re-enable my textarea if this texarea page located isn’t active. From there i can still submit the form, because textarea isn’t on disabled mode.
    That’s my solution.

    I don’t know maybe if we’re on single form we can call beforesubmit instead beforepagechanged (I’m not try yet)

    Is there any other way to achieve this or more elegant solution? @prashantrai

    • This reply was modified 2 years, 7 months ago by taufiqridha.

    Hey @taufiqridha – Thanks for following up on this thread and for sharing the solution!

    While at this moment we don’t have a more efficient solution, I’ll share your feedback with our developers for consideration since it will also require some custom development work which falls outside the scope of support we can provide on www.remarpro.com. In case you’d like to look into custom development options, we highly recommend using Codeable.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Override required field’ is closed to new replies.