• Resolved mranner

    (@mranner)


    Hello there!

    It would be nice to include a static function for setting element values via slug, analog to get_slug_value().

    I use Caldera Forms with some custom form post processing via “caldera_forms_submit_start” hook. A the moment I have to fiddle with the internal structure of the $form array.

    Implementing set_slug_value() to the API would simplify setting form values dynamically on “caldera_forms_submit_start” hook:

    static public function set_slug_data($slug, $value, $form) {

    if (false !== strpos($slug, ‘.’)){
    $slug_parts = explode(‘.’, $slug);
    $slug = array_shift($slug_parts);
    }

    foreach ($form[‘fields’] as $field_id => $field) {

    if ($field[‘slug’] == $slug) {
    self::set_field_data($field_id, $value, $form);
    }

    }

    }

    https://ww.wp.xz.cn/plugins/caldera-forms/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor David Cramer

    (@desertsnowman)

    Good suggestion.

    have you thought about contributing to the github repo? https://github.com/Desertsnowman/Caldera-Forms

    Plugin Contributor David Cramer

    (@desertsnowman)

    I modified get_field_data to accept both the ID or slug. checking the ID first else looking up the ID if a slug is used. so you can now use

    Caldera_Forms::set_field_data( 'id / slug', 'value', $form );

    equally, this is also in get_field_data so techinally get_slug_data is no longer needed. and will be deprecated

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Adding Caldera_Forms::set_slug_value()?’ is closed to new replies.