leapfrognz/alternative-field

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Simple dropdown field which displays a text field when 'Other' is selected. Great for Honorifics selects.

Installs: 26

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 2

Open Issues: 5

Type:silverstripe-module

dev-master 2013-10-14 07:04 UTC

This package is auto-updated.

Last update: 2021-10-06 08:16:43 UTC


README

Introduction

Simple dropdown field which displays a text field when 'Other' is selected. Great for Honorific selects.

How to use

Add the dropdown options to the _config/AlternativeFormField.yml file.

You can also edit the empty string for the dropdown and the label for the 'other' field in the yml.

Requirements

SilverStripe 3.0 or higher is required.

Example

<?php

	public function getCMSFields() {
		$fields = parent::getCMSFields();
		$fields->addFieldsToTab("Root.Whatever", array(
			AlternativeFormField::create('Honorific', 'Honorific'),
			TextField::create('FirstName', 'First name'),
			TextField::create('Surname', 'Last name')
		));

		return $fields;
	}