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);
|
||||
}
|
||||
$output->push(new ArrayData(array(
|
||||
'Name' => $this->Name(),
|
||||
'FieldName' => $this->FieldName(),
|
||||
'Display' => $data['Display'],
|
||||
'Fields' => $outputFields,
|
||||
'ConditionField' => $data['ConditionField'],
|
||||
@ -214,7 +214,7 @@ class EditableFormField extends DataObject {
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public function Name() {
|
||||
public function FieldName() {
|
||||
return "Fields[".$this->ID."]";
|
||||
}
|
||||
|
||||
@ -238,7 +238,7 @@ class EditableFormField extends DataObject {
|
||||
public function populateFromPostData($data) {
|
||||
$this->Title = (isset($data['Title'])) ? $data['Title']: "";
|
||||
$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->Required = !empty($data['Required']) ? 1 : 0;
|
||||
$this->CanDelete = (isset($data['CanDelete']) && !$data['CanDelete']) ? 0 : 1;
|
||||
|
@ -72,7 +72,7 @@ class EditableMultipleOptionField extends EditableFormField {
|
||||
|
||||
// get the current options
|
||||
$fieldSet = $this->Options();
|
||||
|
||||
|
||||
// go over all the current options and check if ID and Title still exists
|
||||
foreach($fieldSet as $option) {
|
||||
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
|
||||
*/
|
||||
public function Name() {
|
||||
public function FieldName() {
|
||||
return "Fields[{$this->ParentID}][{$this->ID}]";
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
class FieldEditor extends FormField {
|
||||
|
||||
protected $haveFormOptions = true;
|
||||
protected $hasFormOptions = true;
|
||||
|
||||
function FieldHolder() {
|
||||
return $this->renderWith("FieldEditor");
|
||||
@ -104,10 +104,11 @@ class FieldEditor extends FormField {
|
||||
} else {
|
||||
$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
|
||||
// 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
|
||||
if(isset($newEditableData['Title']) && $newEditableData['Title'] != 'field-node-deleted') {
|
||||
unset($missingFields[$editable->ID]);
|
||||
@ -129,10 +130,10 @@ class FieldEditor extends FormField {
|
||||
}
|
||||
|
||||
if($record->hasMethod('customFormSave')) {
|
||||
$record->customFormSave( $_REQUEST[$name], $record );
|
||||
$record->customFormSave($_REQUEST[$name], $record);
|
||||
}
|
||||
|
||||
if($record->hasMethod( 'processNewFormFields')) {
|
||||
if($record->hasMethod('processNewFormFields')) {
|
||||
$record->processNewFormFields();
|
||||
}
|
||||
}
|
||||
@ -208,21 +209,21 @@ class FieldEditor extends FormField {
|
||||
return false;
|
||||
}
|
||||
|
||||
function setHaveFormOptions($bool){
|
||||
$this->haveFormOptions = $bool;
|
||||
function setHasFormOptions($bool){
|
||||
$this->hasFormOptions = $bool;
|
||||
}
|
||||
|
||||
function getHaveFormOptions(){
|
||||
return $this->haveFormOptions;
|
||||
function hasFormOptions(){
|
||||
return $this->hasFormOptions;
|
||||
}
|
||||
|
||||
function FormOptions() {
|
||||
if($this->haveFormOptions){
|
||||
if($this->hasFormOptions()){
|
||||
if($this->form->getRecord()->hasMethod('customFormActions')) {
|
||||
$newFields = $this->form->getRecord()->customFormActions($this->readonly);
|
||||
|
||||
foreach( $newFields as $newField ) {
|
||||
$newField->setName( "{$this->name}[{$newField->Name()}]" );
|
||||
|
||||
foreach($newFields as $newField) {
|
||||
$newField->setName("{$this->name}[{$newField->Name()}]" );
|
||||
}
|
||||
if($this->readonly) {
|
||||
$newFields = $newFields->makeReadonly();
|
||||
|
@ -29,13 +29,9 @@
|
||||
<% if HasAddableOptions %>
|
||||
<fieldset class="fieldOptionsGroup">
|
||||
<legend><% _t('OPTIONS', 'Options') %></legend>
|
||||
<ul class="editableOptions" id="$Name.Attr-list">
|
||||
<ul class="editableOptions" id="$FieldName.Attr-list">
|
||||
|
||||
<% if canEdit %>
|
||||
<% control Options %>
|
||||
$ReadonlyOption
|
||||
<% end_control %>
|
||||
<% else %>
|
||||
<% control Options %>
|
||||
$EditSegment
|
||||
<% end_control %>
|
||||
@ -46,6 +42,10 @@
|
||||
</a>
|
||||
</li>
|
||||
<% end_if %>
|
||||
<% else %>
|
||||
<% control Options %>
|
||||
$ReadonlyOption
|
||||
<% end_control %>
|
||||
<% end_if %>
|
||||
</ul>
|
||||
</fieldset>
|
||||
@ -70,14 +70,14 @@
|
||||
<% end_if %>
|
||||
<fieldset class="customRules fieldOptionsGroup">
|
||||
<legend>Custom Rules</legend>
|
||||
<ul id="$Name.Attr-customRules">
|
||||
<ul id="$FieldName.Attr-customRules">
|
||||
<li>
|
||||
<a href="#" class="addCondition" title="<% _t('ADD', 'Add') %>">
|
||||
Add Rule
|
||||
</a>
|
||||
</li>
|
||||
<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="Hide" <% if ShowOnLoad %><% else %>selected="selected"<% end_if %>><% _t('HIDE', 'Hide') %></option>
|
||||
</select>
|
||||
@ -85,18 +85,18 @@
|
||||
<label class="left">Field On Default</label>
|
||||
</li>
|
||||
<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="Hide"><% _t('HIDETHISFIELD', 'Hide This Field') %></option>
|
||||
</select>
|
||||
|
||||
<label><% _t('WHEN', 'When') %></label>
|
||||
<select class="fieldOption customRuleField" name="{$Name}[CustomRules][ConditionField]">
|
||||
<select class="fieldOption customRuleField" name="{$FieldName}[CustomRules][ConditionField]">
|
||||
|
||||
</select>
|
||||
|
||||
<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="IsBlank"><% _t('BLANK', 'Blank') %></option>
|
||||
<option value="IsNotBlank"><% _t('NOTBLANK', 'Not Blank') %></option>
|
||||
@ -104,7 +104,7 @@
|
||||
<option value="ValueNot"><% _t('NOTVALUE', 'Not Value') %></option>
|
||||
</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>
|
||||
</li>
|
||||
@ -119,7 +119,7 @@
|
||||
<% end_if %>
|
||||
|
||||
<!-- Hidden option Fields -->
|
||||
<input type="hidden" class="canDeleteHidden" name="$Name.Attr[CanDelete]" value="$CanDelete" />
|
||||
<input type="hidden" class="typeHidden" name="$Name.Attr[Type]" value="$ClassName" />
|
||||
<input type="hidden" class="sortHidden" name="$Name.Attr[Sort]" value="$Sort" />
|
||||
<input type="hidden" class="canDeleteHidden" name="$FieldName.Attr[CanDelete]" value="$CanDelete" />
|
||||
<input type="hidden" class="typeHidden" name="$FieldName.Attr[Type]" value="$ClassName" />
|
||||
<input type="hidden" class="sortHidden" name="$FieldName.Attr[Sort]" value="$Sort" />
|
||||
</li>
|
@ -1,7 +1,7 @@
|
||||
<li>
|
||||
<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="hidden" class="sortOptionHidden hidden" name="$Name[Sort]" value="$Sort" />
|
||||
<input type="text" name="{$FieldName}[Title]" value="$Title" />
|
||||
<input type="hidden" class="sortOptionHidden hidden" name="{$FieldName}[Sort]" value="$Sort" />
|
||||
|
||||
<% if isReadonly %>
|
||||
<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 %>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user