You are here

protected function AvailabilityCalendarStylesFormBuilder::lengthField in Availability Calendars 7.5

Same name and namespace in other branches
  1. 7.3 availability_calendar.styles.inc \AvailabilityCalendarStylesFormBuilder::lengthField()
  2. 7.4 availability_calendar.styles.inc \AvailabilityCalendarStylesFormBuilder::lengthField()

Helper method to add a length field to a given fieldset.

By extracting this, we get standardized settings for length fields. E.g: for now only pixels are allowed, but this function could add a dropdown for unit selection.

Parameters

string|array $cssProperty: The name of the css color property to add. If this is not the same as the form field name, pass in an array with 1 element: <field name> => <css property>.

4 calls to AvailabilityCalendarStylesFormBuilder::lengthField()
AvailabilityCalendarStylesFormBuilder::fieldsetDays in ./availability_calendar.styles.inc
Helper method to create the fieldset for the day styles.
AvailabilityCalendarStylesFormBuilder::fieldsetHeader in ./availability_calendar.styles.inc
Helper method to create the fieldset for the table header styles.
AvailabilityCalendarStylesFormBuilder::fieldsetTable in ./availability_calendar.styles.inc
Helper method to create the fieldset for the table styles.
AvailabilityCalendarStylesFormBuilder::fieldsetWeekNotes in ./availability_calendar.styles.inc
Helper method to create the fieldset for the week note styles.

File

./availability_calendar.styles.inc, line 239

Class

AvailabilityCalendarStylesFormBuilder

Code

protected function lengthField($cssProperty) {
  if (is_array($cssProperty)) {
    $fieldName = key($cssProperty);
    $cssProperty = current($cssProperty);
  }
  else {
    $fieldName = $cssProperty;
  }
  $this->form[$this->currentFieldset][$fieldName] = array(
    '#type' => 'textfield',
    '#title' => $cssProperty,
    '#default_value' => $this
      ->getStyle($fieldName),
    '#size' => 8,
    '#maxlength' => 6,
    '#field_suffix' => 'px',
  );
}