4

The following code is working for text field, but it's not working for image field.

function THEMENAME_form_system_theme_settings_alter(&$form, FormStateInterface &$form_state, $form_id = NULL) {
  $form['check'] = array(
    '#title' => t("Show Image file"),
    '#type' => 'checkbox',
  );

  $form['banner_image'] = array(
    '#title' => t('User Image'),
    '#type' => 'managed_file',
    '#default_value' => theme_get_setting('banner_image'),
    '#upload_location' => 'public://',
    '#upload_validators' => array(
      'file_validate_extensions' => array('gif png jpg jpeg'),
      'file_validate_size' => array(1048576),
    ),
    '#states' => array(
      "visible" => array(
        "input[name='check']" => array("checked" => TRUE)),
    ),
  );
}

Can any one suggest how to implement this?

  • 1
    It weird because this issue should be committed. – Jimmy Ko Aug 10 '16 at 14:04

Your Answer

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

Browse other questions tagged or ask your own question.