Skip to content

Instantly share code, notes, and snippets.

@Ariex
Last active August 29, 2015 14:25
Show Gist options
  • Save Ariex/57ffc1db828feedda649 to your computer and use it in GitHub Desktop.
Save Ariex/57ffc1db828feedda649 to your computer and use it in GitHub Desktop.

my code as below

$fields->insertBefore($isTrueField = CheckboxField::create('IsTrue', 'Is it true?'), 'OtherField');
$fields->dataFieldByName('AnotherField')->setAttribute('data-attribute', $isTrueField->ID());

the outputs is checkbox

<div id="IsTrue">
	<input type="checkbox" id="SomeForm_SomeForm_IsTrue" name="IsTrue">

another field

<div id="AnotherField">
	<div class="middleColumn">
		<input id="SomeForm_SomeForm_AnotherField" type="text" data-attribute="IsTrue" name="AnotherField">

i am expect data-attribute be 'SomeForm_SomeForm_IsTrue'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment