mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
BUGFIX: fixed naming conflict with method / var name
This commit is contained in:
parent
52e6c99740
commit
8047dec983
@ -188,7 +188,7 @@ class EditableFormField extends DataObject {
|
|||||||
$outputFields->push($new);
|
$outputFields->push($new);
|
||||||
}
|
}
|
||||||
$output->push(new ArrayData(array(
|
$output->push(new ArrayData(array(
|
||||||
'Name' => $this->Name(),
|
'FieldName' => $this->FieldName(),
|
||||||
'Display' => $data['Display'],
|
'Display' => $data['Display'],
|
||||||
'Fields' => $outputFields,
|
'Fields' => $outputFields,
|
||||||
'ConditionField' => $data['ConditionField'],
|
'ConditionField' => $data['ConditionField'],
|
||||||
@ -214,7 +214,7 @@ class EditableFormField extends DataObject {
|
|||||||
*
|
*
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public function Name() {
|
public function FieldName() {
|
||||||
return "Fields[".$this->ID."]";
|
return "Fields[".$this->ID."]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ class EditableFormField extends DataObject {
|
|||||||
public function populateFromPostData($data) {
|
public function populateFromPostData($data) {
|
||||||
$this->Title = (isset($data['Title'])) ? $data['Title']: "";
|
$this->Title = (isset($data['Title'])) ? $data['Title']: "";
|
||||||
$this->Default = (isset($data['Default'])) ? $data['Default'] : "";
|
$this->Default = (isset($data['Default'])) ? $data['Default'] : "";
|
||||||
$this->Sort = isset($data['Sort']) ? $data['Sort'] : null;
|
$this->Sort = (isset($data['Sort'])) ? $data['Sort'] : null;
|
||||||
$this->CustomParameter = isset($data['CustomParameter']) ? $data['CustomParameter'] : null;
|
$this->CustomParameter = isset($data['CustomParameter']) ? $data['CustomParameter'] : null;
|
||||||
$this->Required = !empty($data['Required']) ? 1 : 0;
|
$this->Required = !empty($data['Required']) ? 1 : 0;
|
||||||
$this->CanDelete = (isset($data['CanDelete']) && !$data['CanDelete']) ? 0 : 1;
|
$this->CanDelete = (isset($data['CanDelete']) && !$data['CanDelete']) ? 0 : 1;
|
||||||
|
@ -72,7 +72,7 @@ class EditableMultipleOptionField extends EditableFormField {
|
|||||||
|
|
||||||
// get the current options
|
// get the current options
|
||||||
$fieldSet = $this->Options();
|
$fieldSet = $this->Options();
|
||||||
|
|
||||||
// go over all the current options and check if ID and Title still exists
|
// go over all the current options and check if ID and Title still exists
|
||||||
foreach($fieldSet as $option) {
|
foreach($fieldSet as $option) {
|
||||||
if(isset($data[$option->ID]) && isset($data[$option->ID]['Title']) && $data[$option->ID]['Title'] != "field-node-deleted") {
|
if(isset($data[$option->ID]) && isset($data[$option->ID]['Title']) && $data[$option->ID]['Title'] != "field-node-deleted") {
|
||||||
|
@ -43,7 +43,7 @@ class EditableOption extends DataObject {
|
|||||||
*
|
*
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public function Name() {
|
public function FieldName() {
|
||||||
return "Fields[{$this->ParentID}][{$this->ID}]";
|
return "Fields[{$this->ParentID}][{$this->ID}]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
class FieldEditor extends FormField {
|
class FieldEditor extends FormField {
|
||||||
|
|
||||||
protected $haveFormOptions = true;
|
protected $hasFormOptions = true;
|
||||||
|
|
||||||
function FieldHolder() {
|
function FieldHolder() {
|
||||||
return $this->renderWith("FieldEditor");
|
return $this->renderWith("FieldEditor");
|
||||||
@ -104,10 +104,11 @@ class FieldEditor extends FormField {
|
|||||||
} else {
|
} else {
|
||||||
$editable = DataObject::get_one('EditableFormField', "(`ParentID` = '{$record->ID}' OR `ParentID` = 0) AND `EditableFormField`.`ID`='$newEditableID'" );
|
$editable = DataObject::get_one('EditableFormField', "(`ParentID` = '{$record->ID}' OR `ParentID` = 0) AND `EditableFormField`.`ID`='$newEditableID'" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if we are updating an existing field. One odd thing is a 'deleted' field
|
// check if we are updating an existing field. One odd thing is a 'deleted' field
|
||||||
// still exists in the post data (ID) so we need to check for type.
|
// still exists in the post data (ID) so we need to check for type.
|
||||||
if($editable && isset($missingFields[$editable->ID]) && isset($newEditableData['Type'])) {
|
|
||||||
|
if($editable && isset($missingFields[$editable->ID]) && isset($newEditableData)) {
|
||||||
// check if it has been labelled as deleted
|
// check if it has been labelled as deleted
|
||||||
if(isset($newEditableData['Title']) && $newEditableData['Title'] != 'field-node-deleted') {
|
if(isset($newEditableData['Title']) && $newEditableData['Title'] != 'field-node-deleted') {
|
||||||
unset($missingFields[$editable->ID]);
|
unset($missingFields[$editable->ID]);
|
||||||
@ -129,10 +130,10 @@ class FieldEditor extends FormField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($record->hasMethod('customFormSave')) {
|
if($record->hasMethod('customFormSave')) {
|
||||||
$record->customFormSave( $_REQUEST[$name], $record );
|
$record->customFormSave($_REQUEST[$name], $record);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($record->hasMethod( 'processNewFormFields')) {
|
if($record->hasMethod('processNewFormFields')) {
|
||||||
$record->processNewFormFields();
|
$record->processNewFormFields();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,21 +209,21 @@ class FieldEditor extends FormField {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setHaveFormOptions($bool){
|
function setHasFormOptions($bool){
|
||||||
$this->haveFormOptions = $bool;
|
$this->hasFormOptions = $bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHaveFormOptions(){
|
function hasFormOptions(){
|
||||||
return $this->haveFormOptions;
|
return $this->hasFormOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
function FormOptions() {
|
function FormOptions() {
|
||||||
if($this->haveFormOptions){
|
if($this->hasFormOptions()){
|
||||||
if($this->form->getRecord()->hasMethod('customFormActions')) {
|
if($this->form->getRecord()->hasMethod('customFormActions')) {
|
||||||
$newFields = $this->form->getRecord()->customFormActions($this->readonly);
|
$newFields = $this->form->getRecord()->customFormActions($this->readonly);
|
||||||
|
|
||||||
foreach( $newFields as $newField ) {
|
foreach($newFields as $newField) {
|
||||||
$newField->setName( "{$this->name}[{$newField->Name()}]" );
|
$newField->setName("{$this->name}[{$newField->Name()}]" );
|
||||||
}
|
}
|
||||||
if($this->readonly) {
|
if($this->readonly) {
|
||||||
$newFields = $newFields->makeReadonly();
|
$newFields = $newFields->makeReadonly();
|
||||||
|
@ -29,13 +29,9 @@
|
|||||||
<% if HasAddableOptions %>
|
<% if HasAddableOptions %>
|
||||||
<fieldset class="fieldOptionsGroup">
|
<fieldset class="fieldOptionsGroup">
|
||||||
<legend><% _t('OPTIONS', 'Options') %></legend>
|
<legend><% _t('OPTIONS', 'Options') %></legend>
|
||||||
<ul class="editableOptions" id="$Name.Attr-list">
|
<ul class="editableOptions" id="$FieldName.Attr-list">
|
||||||
|
|
||||||
<% if canEdit %>
|
<% if canEdit %>
|
||||||
<% control Options %>
|
|
||||||
$ReadonlyOption
|
|
||||||
<% end_control %>
|
|
||||||
<% else %>
|
|
||||||
<% control Options %>
|
<% control Options %>
|
||||||
$EditSegment
|
$EditSegment
|
||||||
<% end_control %>
|
<% end_control %>
|
||||||
@ -46,6 +42,10 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
<% else %>
|
||||||
|
<% control Options %>
|
||||||
|
$ReadonlyOption
|
||||||
|
<% end_control %>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
</ul>
|
</ul>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@ -70,14 +70,14 @@
|
|||||||
<% end_if %>
|
<% end_if %>
|
||||||
<fieldset class="customRules fieldOptionsGroup">
|
<fieldset class="customRules fieldOptionsGroup">
|
||||||
<legend>Custom Rules</legend>
|
<legend>Custom Rules</legend>
|
||||||
<ul id="$Name.Attr-customRules">
|
<ul id="$FieldName.Attr-customRules">
|
||||||
<li>
|
<li>
|
||||||
<a href="#" class="addCondition" title="<% _t('ADD', 'Add') %>">
|
<a href="#" class="addCondition" title="<% _t('ADD', 'Add') %>">
|
||||||
Add Rule
|
Add Rule
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="addCustomRule">
|
<li class="addCustomRule">
|
||||||
<select name="$Name.Attr[CustomSettings][ShowOnLoad]">
|
<select name="$FieldName.Attr[CustomSettings][ShowOnLoad]">
|
||||||
<option value="Show" <% if ShowOnLoad %>selected="selected"<% end_if %>><% _t('SHOW', 'Show') %></option>
|
<option value="Show" <% if ShowOnLoad %>selected="selected"<% end_if %>><% _t('SHOW', 'Show') %></option>
|
||||||
<option value="Hide" <% if ShowOnLoad %><% else %>selected="selected"<% end_if %>><% _t('HIDE', 'Hide') %></option>
|
<option value="Hide" <% if ShowOnLoad %><% else %>selected="selected"<% end_if %>><% _t('HIDE', 'Hide') %></option>
|
||||||
</select>
|
</select>
|
||||||
@ -85,18 +85,18 @@
|
|||||||
<label class="left">Field On Default</label>
|
<label class="left">Field On Default</label>
|
||||||
</li>
|
</li>
|
||||||
<li class="hidden">
|
<li class="hidden">
|
||||||
<select class="displayOption customRuleField" name="{$Name}[CustomRules][Display]">
|
<select class="displayOption customRuleField" name="{$FieldName}[CustomRules][Display]">
|
||||||
<option value="Show"><% _t('SHOWTHISFIELD', 'Show This Field') %></option>
|
<option value="Show"><% _t('SHOWTHISFIELD', 'Show This Field') %></option>
|
||||||
<option value="Hide"><% _t('HIDETHISFIELD', 'Hide This Field') %></option>
|
<option value="Hide"><% _t('HIDETHISFIELD', 'Hide This Field') %></option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<label><% _t('WHEN', 'When') %></label>
|
<label><% _t('WHEN', 'When') %></label>
|
||||||
<select class="fieldOption customRuleField" name="{$Name}[CustomRules][ConditionField]">
|
<select class="fieldOption customRuleField" name="{$FieldName}[CustomRules][ConditionField]">
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<label><% _t('IS', 'Is') %></label>
|
<label><% _t('IS', 'Is') %></label>
|
||||||
<select class="conditionOption customRuleField" name="{$Name}[CustomRules][ConditionOption]">
|
<select class="conditionOption customRuleField" name="{$FieldName}[CustomRules][ConditionOption]">
|
||||||
<option value=""></option>
|
<option value=""></option>
|
||||||
<option value="IsBlank"><% _t('BLANK', 'Blank') %></option>
|
<option value="IsBlank"><% _t('BLANK', 'Blank') %></option>
|
||||||
<option value="IsNotBlank"><% _t('NOTBLANK', 'Not Blank') %></option>
|
<option value="IsNotBlank"><% _t('NOTBLANK', 'Not Blank') %></option>
|
||||||
@ -104,7 +104,7 @@
|
|||||||
<option value="ValueNot"><% _t('NOTVALUE', 'Not Value') %></option>
|
<option value="ValueNot"><% _t('NOTVALUE', 'Not Value') %></option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<input type="text" class="ruleValue hidden customRuleField" name="{$Name}[CustomRules][Value]" />
|
<input type="text" class="ruleValue hidden customRuleField" name="{$FieldName}[CustomRules][Value]" />
|
||||||
|
|
||||||
<a href="#" class="deleteCondition" title="<% _t('DELETE', 'Delete') %>"><img src="cms/images/delete.gif" alt="<% _t('DELETE', 'Delete') %>" /></a>
|
<a href="#" class="deleteCondition" title="<% _t('DELETE', 'Delete') %>"><img src="cms/images/delete.gif" alt="<% _t('DELETE', 'Delete') %>" /></a>
|
||||||
</li>
|
</li>
|
||||||
@ -119,7 +119,7 @@
|
|||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
<!-- Hidden option Fields -->
|
<!-- Hidden option Fields -->
|
||||||
<input type="hidden" class="canDeleteHidden" name="$Name.Attr[CanDelete]" value="$CanDelete" />
|
<input type="hidden" class="canDeleteHidden" name="$FieldName.Attr[CanDelete]" value="$CanDelete" />
|
||||||
<input type="hidden" class="typeHidden" name="$Name.Attr[Type]" value="$ClassName" />
|
<input type="hidden" class="typeHidden" name="$FieldName.Attr[Type]" value="$ClassName" />
|
||||||
<input type="hidden" class="sortHidden" name="$Name.Attr[Sort]" value="$Sort" />
|
<input type="hidden" class="sortHidden" name="$FieldName.Attr[Sort]" value="$Sort" />
|
||||||
</li>
|
</li>
|
@ -1,7 +1,7 @@
|
|||||||
<li>
|
<li>
|
||||||
<img class="handle" src="sapphire/images/drag.gif" alt="<% _t('DRAG', 'Drag to rearrange order of options') %>" />
|
<img class="handle" src="sapphire/images/drag.gif" alt="<% _t('DRAG', 'Drag to rearrange order of options') %>" />
|
||||||
<input type="text" name="$Name.Attr[Title]" value="$Title" />
|
<input type="text" name="{$FieldName}[Title]" value="$Title" />
|
||||||
<input type="hidden" class="sortOptionHidden hidden" name="$Name[Sort]" value="$Sort" />
|
<input type="hidden" class="sortOptionHidden hidden" name="{$FieldName}[Sort]" value="$Sort" />
|
||||||
|
|
||||||
<% if isReadonly %>
|
<% if isReadonly %>
|
||||||
<img src="cms/images/locked.gif" alt="<% _t('LOCKED', 'These fields cannot be modified') %>" />
|
<img src="cms/images/locked.gif" alt="<% _t('LOCKED', 'These fields cannot be modified') %>" />
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<div class="FieldEditor <% if isReadonly %>readonly<% end_if %>" id="Fields" name="$Name.Attr">
|
<div class="FieldEditor <% if isReadonly %>readonly<% end_if %>" id="Fields">
|
||||||
|
|
||||||
<% include AddField %>
|
<% include AddField %>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user