Follow us on

Codestar Support Forum » WordPress Plugins » Codestar Framework

Anyway to pass value through callback field?

  1. Hello, I am creating a group of fields. and there is a callback field, I want to pass a value from another field but under the same group, is there any way to do this?
    thank you

    Posted 1 year ago #

  2. Codestar
    Admin

    Hi,

    It can be possible with "sanitize" feature: https://codestarframework.com/documentation/#/faq?id=how-to-use-sanitize-

    array(
      'id'       => 'opt-group',
      'type'     => 'group',
      'title'    => 'Group',
      'sanitize' => 'tuyenvandovn_pass_values',
      'fields'    => array(
        ...
        ...
        ...
      ),
    ),CopyCopied!
    function tuyenvandovn_pass_values( $value ) {
    
      // uncomment below code and see all values. ( disable ajax save for see all values later you can enable ajax save again )
      // var_dump( $value ); exit;
    
      $value[2]['title'] = $value[1]['title']; // for eg. it will update "group 1 title field" to "group 2 title field"
    
      return $value;
    
    }CopyCopied!

    Regards, Codestar

    Posted 1 year ago #
  3. it works. thank you

    Posted 1 year ago #

  4. Codestar
    Admin

    You're welcome

    Posted 1 year ago #