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

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.

|improve this answer|||||
  • Its a custom form. – Jessica Dec 13 '16 at 7:09

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.