0

I'm using #after_build in one of my custom module form like follows

  $form['profile_image'] = array (
    '#type' => 'managed_file',
     '#after_build' => array("change_pic"),
  );

and the function is

function change_pic($element, &$form_state, $form) {
  if($form_state['values']['profile_image']['fid'] != 0){
    // my code goes here..
    return $element;
  }
}

It's working fine in PHP 5x version. but throws the following error in PHP 7x version.

ArgumentCountError: Too few arguments to function change_pic(), 2 passed How can we handle this in PHP 7?

Any inputs would be helpful.

1

There are only 2 args to an after build method, the element and the form state.

Just remove the extra one and it’ll work:

function change_pic($element, &$form_state)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.