0

By default the boolean fields' value displayed as 0/1 when user filled the checkbox field under custom configuration form. Need to render True/False instead of 0/1.

$form['newfield'][$id]['required'] = array(
  '#type' => 'checkbox', 
  '#default_value' => ($config[$id]['required'] ? $config[$id]['required'] : $field['required_disabled']), 
  '#disabled' => $field['required_disabled'], 
);

public function submitForm(array & $form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);
    $config = $this - > config($this - > configId);
    $fields = static::getFields();
    $values = $form_state - > getValues();
    $values = $values['newfield'];
    foreach($values as $key => $field) {
        $config_values[$key] = array('visible' => $field['visible'], 'required' => $field['required'], );
    }
}

1 Answer 1

1

In drupal8, you can easily handle this from "Manage Display" of your content type.

Go to /admin/structure/types/manage/article/display Select your "view_mode". Ex- Default.

enter image description here

Go to the boolean field and click on its settings icon which is placed at atmost right side of the field. Change the output format to "True/False".

enter image description here

Hope, this works for you.

1
  • Its a custom form.
    – Jessica
    Commented Dec 13, 2016 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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