mirror of
https://github.com/processwire/processwire.git
synced 2025-08-17 12:10:45 +02:00
Update several Inputfield modules to remove unnecessary newlines in markup and add phpdocs where appropriate
This commit is contained in:
@@ -42,15 +42,15 @@ class InputfieldWrapper extends Inputfield implements \Countable, \IteratorAggre
|
||||
*
|
||||
*/
|
||||
static protected $defaultMarkup = array(
|
||||
'list' => "\n<ul {attrs}>\n{out}\n</ul>\n",
|
||||
'item' => "\n\t<li {attrs}>\n{out}\n\t</li>",
|
||||
'item_label' => "\n\t\t<label class='InputfieldHeader ui-widget-header{class}' for='{for}'>{out}</label>",
|
||||
'item_label_hidden' => "\n\t\t<label class='InputfieldHeader InputfieldHeaderHidden ui-widget-header{class}'><span>{out}</span></label>",
|
||||
'item_content' => "\n\t\t<div class='InputfieldContent ui-widget-content{class}'>\n{out}\n\t\t</div>",
|
||||
'item_error' => "\n<p class='InputfieldError ui-state-error'><i class='fa fa-fw fa-flash'></i><span>{out}</span></p>",
|
||||
'item_description' => "\n<p class='description'>{out}</p>",
|
||||
'item_head' => "\n<h2>{out}</h2>",
|
||||
'item_notes' => "\n<p class='notes'>{out}</p>",
|
||||
'list' => "<ul {attrs}>{out}</ul>",
|
||||
'item' => "<li {attrs}>{out}</li>",
|
||||
'item_label' => "<label class='InputfieldHeader ui-widget-header{class}' for='{for}'>{out}</label>",
|
||||
'item_label_hidden' => "<label class='InputfieldHeader InputfieldHeaderHidden ui-widget-header{class}'><span>{out}</span></label>",
|
||||
'item_content' => "<div class='InputfieldContent ui-widget-content{class}'>{out}</div>",
|
||||
'item_error' => "<p class='InputfieldError ui-state-error'><i class='fa fa-fw fa-flash'></i><span>{out}</span></p>",
|
||||
'item_description' => "<p class='description'>{out}</p>",
|
||||
'item_head' => "<h2>{out}</h2>",
|
||||
'item_notes' => "<p class='notes'>{out}</p>",
|
||||
'item_icon' => "<i class='fa fa-fw fa-{name}'></i> ",
|
||||
'item_toggle' => "<i class='toggle-icon fa fa-fw fa-angle-down' data-to='fa-angle-down fa-angle-right'></i>",
|
||||
// ALSO:
|
||||
@@ -900,7 +900,7 @@ class InputfieldWrapper extends Inputfield implements \Countable, \IteratorAggre
|
||||
* #pw-internal
|
||||
*
|
||||
* @param bool $clear Set to true in order to clear the delayed children list.
|
||||
* @return array
|
||||
* @return array|Inputfield[]
|
||||
*
|
||||
*/
|
||||
public function _getDelayedChildren($clear = false) {
|
||||
|
@@ -19,7 +19,8 @@
|
||||
* @property-read string $filename full disk path to the file on the server.
|
||||
* @property-read string $name Returns the filename without the path, same as the "basename" property.
|
||||
* @property-read string $hash Get a unique hash (for the page) representing this Pagefile.
|
||||
* @property-read string $tagsArray Get file tags as an array. #pw-group-tags @since 3.0.17
|
||||
* @property-read string $tagsArray Get file tags as an array. #pw-group-tags @since 3.0.17
|
||||
* @property-read int $sort Sort order in database. #pw-group-other
|
||||
* @property string $basename Returns the filename without the path.
|
||||
* @property string $description Value of the file’s description field (string), if enabled. Note you can also set this property directly.
|
||||
* @property string $tags Value of the file’s tags field (string), if enabled. #pw-group-tags
|
||||
|
@@ -23,6 +23,8 @@
|
||||
*
|
||||
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
|
||||
* https://processwire.com
|
||||
*
|
||||
* @method WireArray and($items = null)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@@ -498,6 +498,7 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList {
|
||||
$forIDs = null;
|
||||
if($loading == FieldtypeRepeater::loadingAll && $collapse != FieldtypeRepeater::collapseNone) $forIDs = array();
|
||||
list($editorUrl, $queryString) = explode('?', $this->page->editUrl());
|
||||
if($queryString) {}
|
||||
|
||||
$this->wire('config')->js('InputfieldRepeater', array(
|
||||
'editorUrl' => $editorUrl,
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
/**
|
||||
* A Page List Selector for selecting a single page
|
||||
*
|
||||
* @property int|bool $usePageEdit
|
||||
*
|
||||
*/
|
||||
class InputfieldAsmSelect extends InputfieldSelectMultiple implements InputfieldHasArrayValue {
|
||||
@@ -69,7 +71,7 @@ class InputfieldAsmSelect extends InputfieldSelectMultiple implements Inputfield
|
||||
$this->wire('modules')->get('JqueryUI')->use('modal');
|
||||
}
|
||||
|
||||
if($this->hasFieldtype == 'FieldtypePage' && $this->usePageEdit && !$this->editLink) {
|
||||
if($this->hasFieldtype == 'FieldtypePage' && $this->usePageEdit && empty($this->asmOptions['editLink'])) {
|
||||
$this->setAsmSelectOption('editLink', $this->wire('config')->urls->admin . 'page/edit/?id={value}');
|
||||
$this->setAsmSelectOption('editLinkOnlySelected', false);
|
||||
$this->setAsmSelectOption('editLinkButtonSelector', ".InputfieldSubmit button.ui-button:visible");
|
||||
|
@@ -5,6 +5,7 @@
|
||||
*
|
||||
* @property string $href URL to link to
|
||||
* @property string $aclass Optional class name(s) for <a> element (if href is used).
|
||||
* @property string $target Link target
|
||||
*
|
||||
*/
|
||||
class InputfieldButton extends InputfieldSubmit {
|
||||
|
@@ -167,6 +167,9 @@ class InputfieldCKEditor extends InputfieldTextarea {
|
||||
* Toolbar items split by commas
|
||||
* Groups of toolbar items split by lines
|
||||
* Toolbar lines that starts with '#' are ignored
|
||||
*
|
||||
* @param string $str
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
protected function toolbarStringToArray($str) {
|
||||
@@ -299,7 +302,7 @@ class InputfieldCKEditor extends InputfieldTextarea {
|
||||
if($this->contentsInlineCss) {
|
||||
$this->config->styles->add($this->pathFromRoot($this->contentsInlineCss, true));
|
||||
} else {
|
||||
$this->config->styles->add($this->config->urls->InputfieldCKEditor . "contents-inline.css");
|
||||
$this->config->styles->add($this->config->urls('InputfieldCKEditor') . "contents-inline.css");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,7 +406,7 @@ class InputfieldCKEditor extends InputfieldTextarea {
|
||||
if($this->wire('files')->mkdir($path, true)) {
|
||||
$this->message("Created new CKEditor external plugins directory: $url");
|
||||
} else {
|
||||
$this->error("The CKEditor external plugins directory does not exist: $url - Please create it when/if you want to install external plugins.", Notice::warning);
|
||||
$this->warning("The CKEditor external plugins directory does not exist: $url - Please create it when/if you want to install external plugins.");
|
||||
}
|
||||
}
|
||||
continue;
|
||||
@@ -463,6 +466,9 @@ class InputfieldCKEditor extends InputfieldTextarea {
|
||||
* Clean up a value that will be sent to/from the editor
|
||||
*
|
||||
* This is primarily for HTML Purifier
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
protected function purifyValue($value) {
|
||||
@@ -517,6 +523,9 @@ class InputfieldCKEditor extends InputfieldTextarea {
|
||||
* Process data submitted to a CKEditor field
|
||||
*
|
||||
* When inline mode is used, the content is run through HTML Purifier
|
||||
*
|
||||
* @param WireInputData $input
|
||||
* @return $this
|
||||
*
|
||||
*/
|
||||
public function ___processInput(WireInputData $input) {
|
||||
@@ -637,9 +646,11 @@ class InputfieldCKEditor extends InputfieldTextarea {
|
||||
if($f) $inputfields->remove($f);
|
||||
}
|
||||
|
||||
/** @var InputfieldFieldset $wrapper */
|
||||
$wrapper = $this->wire('modules')->get('InputfieldFieldset');
|
||||
$wrapper->label = $this->_('CKEditor Settings');
|
||||
|
||||
/** @var InputfieldTextarea $f */
|
||||
$f = $this->wire('modules')->get('InputfieldTextarea');
|
||||
$f->attr('name', 'toolbar');
|
||||
$f->attr('value', $this->toolbar);
|
||||
@@ -650,6 +661,7 @@ class InputfieldCKEditor extends InputfieldTextarea {
|
||||
|
||||
$purifierInstalled = $this->wire('modules')->isInstalled('MarkupHTMLPurifier');
|
||||
|
||||
/** @var InputfieldRadios $f */
|
||||
$f = $this->wire('modules')->get('InputfieldRadios');
|
||||
$f->attr('name', 'inlineMode');
|
||||
$f->label = $this->_('Editor Mode');
|
||||
@@ -782,11 +794,13 @@ class InputfieldCKEditor extends InputfieldTextarea {
|
||||
$this->_('only for this CKEditor field');
|
||||
$wrapper->add($f);
|
||||
|
||||
/** @var InputfieldFieldset $fieldset */
|
||||
$fieldset = $this->modules->get('InputfieldFieldset');
|
||||
$fieldset->attr('name', '_plugins_fieldset');
|
||||
$fieldset->label = $this->_('Plugins');
|
||||
$wrapper->add($fieldset);
|
||||
|
||||
|
||||
/** @var InputfieldCheckboxes $f */
|
||||
$f = $this->modules->get('InputfieldCheckboxes');
|
||||
$f->attr('name', 'extraPlugins');
|
||||
$f->label = $this->_('Extra Plugins');
|
||||
|
@@ -106,7 +106,7 @@ class InputfieldCheckbox extends Inputfield {
|
||||
$this->checkedValueIsLabel = false;
|
||||
}
|
||||
// autocheck mode: when non-zero 'value' set, then 'checked=checked' is assumed
|
||||
if($this->autocheck || $this->formBuilder) $this->attr('checked', 'checked');
|
||||
if($this->autocheck || $this->getSetting('formBuilder')) $this->attr('checked', 'checked');
|
||||
}
|
||||
|
||||
|
||||
|
@@ -40,6 +40,7 @@ class InputfieldCheckboxes extends InputfieldSelectMultiple implements Inputfiel
|
||||
$entityEncode = $this->getSetting('entityEncodeText') === false ? false : true;
|
||||
|
||||
if($this->table) {
|
||||
/** @var MarkupAdminDataTable $table */
|
||||
$table = $this->modules->get("MarkupAdminDataTable");
|
||||
$table->setEncodeEntities(false);
|
||||
$table->addClass('pw-no-select');
|
||||
@@ -62,7 +63,7 @@ class InputfieldCheckboxes extends InputfieldSelectMultiple implements Inputfiel
|
||||
$ulClass = 'InputfieldCheckboxesStacked';
|
||||
}
|
||||
|
||||
if(!$table) $out = "\n<ul class='$ulClass'>";
|
||||
if(!$table) $out = "<ul class='$ulClass'>";
|
||||
|
||||
foreach($this->getOptions() as $key => $value) {
|
||||
$checked = '';
|
||||
@@ -92,13 +93,13 @@ class InputfieldCheckboxes extends InputfieldSelectMultiple implements Inputfiel
|
||||
$table->row($value);
|
||||
} else {
|
||||
//$value = str_replace(' ', ' <wbr>', $value);
|
||||
$out .= "\n\t<li$liAttr>$input<span class='pw-no-select'>$value</span></label></li>";
|
||||
$out .= "<li$liAttr>$input<span class='pw-no-select'>$value</span></label></li>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($table) $out .= $table->render();
|
||||
else $out .= "\n</ul>";
|
||||
else $out .= "</ul>";
|
||||
|
||||
return $out;
|
||||
|
||||
@@ -115,6 +116,7 @@ class InputfieldCheckboxes extends InputfieldSelectMultiple implements Inputfiel
|
||||
|
||||
public function ___getConfigInputfields() {
|
||||
$inputfields = parent::___getConfigInputfields();
|
||||
/** @var InputfieldInteger $f */
|
||||
$f = $this->wire('modules')->get('InputfieldInteger');
|
||||
$f->label = $this->_('Columns of Checkboxes');
|
||||
$f->description = $this->_('If you want the checkboxes to display in columns (rather than stacked), enter the number of columns you want to use (up to 10). To display checkboxes side-by-side (inline) enter 1.');
|
||||
|
@@ -173,7 +173,7 @@ class InputfieldDatetime extends Inputfield {
|
||||
if(empty($value)) $value = '';
|
||||
$yearRange = $sanitizer->entities($this->yearRange);
|
||||
|
||||
$out = "\n" .
|
||||
$out =
|
||||
"<input " . $this->getAttributesString($attrs) . " " .
|
||||
"value='$value' " .
|
||||
"data-dateformat='$dateFormatJS' " .
|
||||
@@ -400,7 +400,7 @@ class InputfieldDatetime extends Inputfield {
|
||||
$f->columnWidth = 50;
|
||||
$inputfields->append($f);
|
||||
|
||||
/** @var InputfieldText $f */
|
||||
/** @var InputfieldText $field */
|
||||
$field = $this->modules->get('InputfieldText');
|
||||
$field->setAttribute('name', 'placeholder');
|
||||
$field->label = $this->_('Placeholder Text');
|
||||
|
@@ -33,14 +33,14 @@ class InputfieldEmail extends InputfieldText {
|
||||
if(!$this->label || $this->label == $this->name) $this->label = $this->_('E-Mail'); // label headline when no default specified
|
||||
if($this->confirm && count($this->getErrors())) $this->attr('value', '');
|
||||
$attrs = $this->getAttributes();
|
||||
$out = "\n<input " . $this->getAttributesString($attrs) . " />";
|
||||
$out = "<input " . $this->getAttributesString($attrs) . " />";
|
||||
if($this->confirm) {
|
||||
foreach(array('id', 'name') as $key) {
|
||||
if(isset($attrs[$key])) $attrs[$key] = '_' . $attrs[$key] . '_confirm';
|
||||
}
|
||||
$attrs['aria-label'] = $this->confirmLabel;
|
||||
$attrs['placeholder'] = $this->confirmLabel;
|
||||
$out .= "\n<div style='margin-top: 0.5em;'><input " . $this->getAttributesString($attrs) . " /></div>";
|
||||
$out .= "<div style='margin-top: 0.5em;'><input " . $this->getAttributesString($attrs) . " /></div>";
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
@@ -75,6 +75,7 @@ class InputfieldEmail extends InputfieldText {
|
||||
if($f) $inputfields->remove($f);
|
||||
}
|
||||
|
||||
/** @var InputfieldCheckbox $f */
|
||||
$f = $this->wire('modules')->get('InputfieldCheckbox');
|
||||
$f->attr('name', 'confirm');
|
||||
$f->label = $this->_('Confirm email address?');
|
||||
|
@@ -14,7 +14,7 @@ class InputfieldFieldset extends InputfieldWrapper {
|
||||
public function ___render() {
|
||||
// Note the extra "\n" is required in order to prevent InputfieldWrapper from
|
||||
// skipping over an empty fieldset. Empty fieldsets are used by InputfieldRepeater
|
||||
// for thier description/label, and possibly others use it the same way.
|
||||
// for their description/label, and possibly others use it the same way.
|
||||
return parent::___render() . "\n";
|
||||
}
|
||||
|
||||
|
@@ -19,6 +19,15 @@
|
||||
* @property bool|int $noCollapseItem Set to true to disable collapsed items (like for LanguageTranslator tool or other things that add tools to files)
|
||||
* @property bool|int $noShortName Set to true to disable shortened filenames in output
|
||||
* @property bool|int $noCustomButton Set to true to disable use of the styled <input type='file'>
|
||||
*
|
||||
* @method string renderItem($pagefile, $id, $n)
|
||||
* @method string renderList($value)
|
||||
* @method string renderUpload($value)
|
||||
* @method void fileAdded(Pagefile $pagefile)
|
||||
* @method array extractMetadata(Pagefile $pagefile, array $metadata = array())
|
||||
* @method void processInputAddFile($filename)
|
||||
* @method void processInputDeleteFile(Pagefile $pagefile)
|
||||
* @method bool processInputFile(WireInputData $input, Pagefile $pagefile, $n)
|
||||
*
|
||||
*/
|
||||
class InputfieldFile extends Inputfield implements InputfieldItemList {
|
||||
@@ -181,7 +190,7 @@ class InputfieldFile extends Inputfield implements InputfieldItemList {
|
||||
* Set the parent of this Inputfield
|
||||
*
|
||||
* @param InputfieldWrapper $parent
|
||||
* @return this
|
||||
* @return $this
|
||||
*
|
||||
*/
|
||||
public function setParent(InputfieldWrapper $parent) {
|
||||
@@ -195,7 +204,8 @@ class InputfieldFile extends Inputfield implements InputfieldItemList {
|
||||
}
|
||||
|
||||
protected function renderItemDescriptionField(Pagefile $pagefile, $id, $n) {
|
||||
|
||||
|
||||
if($n) {}
|
||||
$out = '';
|
||||
$tabs = '';
|
||||
static $hasLangTabs = null;
|
||||
@@ -317,26 +327,26 @@ class InputfieldFile extends Inputfield implements InputfieldItemList {
|
||||
$deleteLabel = $this->labels['delete'];
|
||||
|
||||
$out =
|
||||
"\n\t\t<p class='InputfieldFileInfo InputfieldItemHeader ui-state-default ui-widget-header'>" .
|
||||
"\n\t\t\t" . wireIconMarkupFile($pagefile->basename, "fa-fw HideIfEmpty") .
|
||||
"\n\t\t\t<a class='InputfieldFileName' title='$pagefile->basename' target='_blank' href='{$pagefile->url}'>$displayName</a> " .
|
||||
"\n\t\t\t<span class='InputfieldFileStats'>" . str_replace(' ', ' ', $pagefile->filesizeStr) . "</span> ";
|
||||
"<p class='InputfieldFileInfo InputfieldItemHeader ui-state-default ui-widget-header'>" .
|
||||
wireIconMarkupFile($pagefile->basename, "fa-fw HideIfEmpty") .
|
||||
"<a class='InputfieldFileName' title='$pagefile->basename' target='_blank' href='{$pagefile->url}'>$displayName</a> " .
|
||||
"<span class='InputfieldFileStats'>" . str_replace(' ', ' ', $pagefile->filesizeStr) . "</span> ";
|
||||
|
||||
if(!$this->renderValueMode) $out .=
|
||||
"\n\t\t\t<label class='InputfieldFileDelete'>" .
|
||||
"<label class='InputfieldFileDelete'>" .
|
||||
"<input type='checkbox' name='delete_$id' value='1' title='$deleteLabel' />" .
|
||||
"<i class='fa fa-fw fa-trash'></i></label>";
|
||||
|
||||
$out .=
|
||||
"\n\t\t</p>" .
|
||||
"\n\t\t<div class='InputfieldFileData description ui-widget-content'>" .
|
||||
"\n\t\t\t" . $this->renderItemDescriptionField($pagefile, $id, $n);
|
||||
"</p>" .
|
||||
"<div class='InputfieldFileData description ui-widget-content'>" .
|
||||
$this->renderItemDescriptionField($pagefile, $id, $n);
|
||||
|
||||
if(!$this->renderValueMode) $out .=
|
||||
"\n\t\t\t<input class='InputfieldFileSort' type='text' name='sort_$id' value='$n' />";
|
||||
"<input class='InputfieldFileSort' type='text' name='sort_$id' value='$n' />";
|
||||
|
||||
$out .=
|
||||
"\n\t\t</div>";
|
||||
"</div>";
|
||||
|
||||
return $out;
|
||||
}
|
||||
@@ -347,7 +357,7 @@ class InputfieldFile extends Inputfield implements InputfieldItemList {
|
||||
// they will get strict notices from php if we add a new argument here.
|
||||
$item = $this->currentItem;
|
||||
$id = $item && !$this->renderValueMode ? " id='file_$item->hash'" : "";
|
||||
return "\n\t<li$id class='{$this->itemClass}'>$out\n\t</li>";
|
||||
return "<li$id class='{$this->itemClass}'>$out</li>";
|
||||
}
|
||||
|
||||
protected function renderListReady($value) {
|
||||
@@ -380,12 +390,13 @@ class InputfieldFile extends Inputfield implements InputfieldItemList {
|
||||
|
||||
$class = 'InputfieldFileList ui-helper-clearfix';
|
||||
if($this->overwrite && !$this->renderValueMode) $class .= " InputfieldFileOverwrite";
|
||||
if($out) $out = "\n<ul class='$class'>$out\n</ul>";
|
||||
if($out) $out = "<ul class='$class'>$out</ul>";
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
protected function ___renderUpload($value) {
|
||||
if($value) {}
|
||||
if($this->noUpload || $this->renderValueMode) return '';
|
||||
|
||||
// enables user to choose more than one file
|
||||
@@ -570,6 +581,7 @@ class InputfieldFile extends Inputfield implements InputfieldItemList {
|
||||
}
|
||||
|
||||
$this->value->add($filename);
|
||||
/** @var Pagefile $item */
|
||||
$item = $this->value->last();
|
||||
|
||||
try {
|
||||
@@ -610,6 +622,7 @@ class InputfieldFile extends Inputfield implements InputfieldItemList {
|
||||
if($replace) {
|
||||
if(strpos($replace, '?') !== false) {
|
||||
list($replace, $unused) = explode('?', $replace);
|
||||
if($unused) {}
|
||||
}
|
||||
$replaceFile = $this->value->getFile($replace);
|
||||
if($replaceFile && $replaceFile instanceof Pagefile) {
|
||||
@@ -766,9 +779,11 @@ class InputfieldFile extends Inputfield implements InputfieldItemList {
|
||||
/**
|
||||
* Send an ajax response
|
||||
*
|
||||
* $error bool Whether it was successful
|
||||
* $message string Message you want to return
|
||||
* $file string Full path and filename or blank if not applicable
|
||||
* @param bool $error Whether it was successful
|
||||
* @param string $message Message you want to return
|
||||
* @param string $file Full path and filename or blank if not applicable
|
||||
* @param string $size
|
||||
* @param string $markup
|
||||
*
|
||||
*/
|
||||
protected function ajaxResponse($error, $message, $file = '', $size = '', $markup = '') {
|
||||
@@ -825,7 +840,8 @@ class InputfieldFile extends Inputfield implements InputfieldItemList {
|
||||
*/
|
||||
public function ___getConfigInputfields() {
|
||||
$inputfields = parent::___getConfigInputfields();
|
||||
|
||||
|
||||
/** @var InputfieldCheckbox $f */
|
||||
$f = $this->modules->get("InputfieldCheckbox");
|
||||
$f->attr('name', 'unzip');
|
||||
$f->attr('value', 1);
|
||||
@@ -863,8 +879,6 @@ class InputfieldFile extends Inputfield implements InputfieldItemList {
|
||||
$inputfields->append($f);
|
||||
}
|
||||
|
||||
// @todo make noAjax option configurable
|
||||
|
||||
return $inputfields;
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,12 @@
|
||||
<?php namespace ProcessWire;
|
||||
|
||||
/**
|
||||
* Inputfield for floating point numbers
|
||||
*
|
||||
* @property int $precision
|
||||
*
|
||||
*/
|
||||
|
||||
class InputfieldFloat extends InputfieldInteger {
|
||||
|
||||
public static function getModuleInfo() {
|
||||
@@ -34,6 +41,9 @@ class InputfieldFloat extends InputfieldInteger {
|
||||
* Returns true if number is in valid range, false if not
|
||||
*
|
||||
* Overriding the function from InputfieldInteger to ensure float types (rather than int types) are used
|
||||
*
|
||||
* @param float $value
|
||||
* @return bool
|
||||
*
|
||||
*/
|
||||
protected function isInRange($value) {
|
||||
|
@@ -9,7 +9,8 @@
|
||||
* @property bool $protectCSRF Set to false to disable automatic CSRF protection
|
||||
* @property int $columnWidthSpacing Optionally set the column width spacing (pixels)
|
||||
* @property string $description Optionally set a description headline for the form
|
||||
* @property string $confirmText Confirmation text that precedes list of changes (when class InputfieldFormConfirm is active)
|
||||
* @property string $confirmText Confirmation text that precedes list of changes (when class InputfieldFormConfirm is
|
||||
* active)
|
||||
* @property string $method Form method attribute (default="post")
|
||||
* @property string $action Form action attribute (default="./")
|
||||
*
|
||||
@@ -127,12 +128,13 @@ class InputfieldForm extends InputfieldWrapper {
|
||||
$tokenField = '';
|
||||
}
|
||||
|
||||
$out = "\n<form $attrStr>" .
|
||||
$out =
|
||||
"<form $attrStr>" .
|
||||
$description . $this->getSetting('prependMarkup') .
|
||||
parent::___render() .
|
||||
$tokenField .
|
||||
$this->getSetting('appendMarkup') .
|
||||
"\n</form>";
|
||||
"</form>";
|
||||
|
||||
return $out;
|
||||
}
|
||||
@@ -167,7 +169,8 @@ class InputfieldForm extends InputfieldWrapper {
|
||||
$delayedN = count($delayedChildren);
|
||||
$processedN = 0;
|
||||
$unprocessedN = 0;
|
||||
|
||||
|
||||
/** @var Inputfield[] $savedChildren */
|
||||
$savedChildren = $delayedChildren;
|
||||
|
||||
while(count($delayedChildren)) {
|
||||
@@ -191,6 +194,7 @@ class InputfieldForm extends InputfieldWrapper {
|
||||
|
||||
// whether we should process $child now or not
|
||||
$processNow = true;
|
||||
$selector = null;
|
||||
|
||||
foreach($selectors as $selector) {
|
||||
|
||||
@@ -204,8 +208,8 @@ class InputfieldForm extends InputfieldWrapper {
|
||||
|
||||
// if field had already been through the loop, but was not processed, add it back in for processing
|
||||
if(!isset($delayedChildren[$name])
|
||||
&& !$savedChildren[$name]->showIfProcessed
|
||||
&& !$savedChildren[$name]->showIfSkipped) {
|
||||
&& !$savedChildren[$name]->getSetting('showIfProcessed')
|
||||
&& !$savedChildren[$name]->getSetting('showIfSkipped')) {
|
||||
$delayedChildren[$name] = $savedChildren[$name];
|
||||
}
|
||||
|
||||
@@ -214,13 +218,13 @@ class InputfieldForm extends InputfieldWrapper {
|
||||
$savedChildren[$name]->showIf = '1>0'; // forced match
|
||||
}
|
||||
|
||||
if($savedChildren[$name]->showIfSkipped) {
|
||||
if($savedChildren[$name]->getSetting('showIfSkipped')) {
|
||||
// dependency $field does not need to be processed, so neither does this field
|
||||
unset($delayedChildren[$child->name]);
|
||||
$processNow = false;
|
||||
if(self::debug) $this->debugNote("Removing field '$child->name' because '$name' it not shown.");
|
||||
|
||||
} else if(!$savedChildren[$name]->showIfProcessed) {
|
||||
} else if(!$savedChildren[$name]->getSetting('showIfProcessed')) {
|
||||
// dependency $field is another one in $delayedChildren, send it back to the end
|
||||
unset($delayedChildren[$child->name]);
|
||||
// put it back on the end
|
||||
@@ -305,7 +309,7 @@ class InputfieldForm extends InputfieldWrapper {
|
||||
* Process input for fields with a required-if dependency
|
||||
*
|
||||
* @param WireInputData $input
|
||||
* @param array $delayedChildren
|
||||
* @param array|Inputfield[] $delayedChildren
|
||||
* @return bool
|
||||
*
|
||||
*/
|
||||
@@ -313,7 +317,7 @@ class InputfieldForm extends InputfieldWrapper {
|
||||
|
||||
// process input for any remaining delayedChildren not already processed by processInputShowIf
|
||||
foreach($delayedChildren as $child) {
|
||||
if($child->showIfSkipped || $child->showIfProcessed) continue;
|
||||
if($child->getSetting('showIfSkipped') || $child->getSetting('showIfProcessed')) continue;
|
||||
if(self::debug) $this->debugNote("Now Processing requiredIf delayed child: $child->name");
|
||||
$child->processInput($input);
|
||||
}
|
||||
@@ -326,7 +330,7 @@ class InputfieldForm extends InputfieldWrapper {
|
||||
|
||||
|
||||
// if field was not shown, then it can't be required
|
||||
if($child->showIfSkipped) continue;
|
||||
if($child->getSetting('showIfSkipped')) continue;
|
||||
|
||||
$required = true;
|
||||
$selectorString = $child->getSetting('requiredIf');
|
||||
@@ -374,7 +378,7 @@ class InputfieldForm extends InputfieldWrapper {
|
||||
* Does the selector match the given Inputfield name?
|
||||
*
|
||||
* @param Selector $selector
|
||||
* @param $name Name of Inputfield
|
||||
* @param string $name Name of Inputfield
|
||||
* @param string $debugNote Optional qualifier note for debugging
|
||||
* @return bool|null Returns true|false if match determined, or NULL if $name is not present in form
|
||||
*
|
||||
|
@@ -22,7 +22,7 @@ class InputfieldHidden extends Inputfield {
|
||||
}
|
||||
|
||||
public function ___render() {
|
||||
return "\n<input " . $this->getAttributesString() . " />";
|
||||
return "<input " . $this->getAttributesString() . " />";
|
||||
}
|
||||
|
||||
public function getAttributes() {
|
||||
@@ -41,6 +41,7 @@ class InputfieldHidden extends Inputfield {
|
||||
$f = $inputfields->getChildByName('columnWidth');
|
||||
$inputfields->remove($f);
|
||||
|
||||
/** @var InputfieldText $field */
|
||||
$field = $this->modules->get('InputfieldText');
|
||||
$field->setAttribute('name', 'initValue');
|
||||
$field->label = $this->_('Value');
|
||||
|
@@ -1,5 +1,11 @@
|
||||
<?php namespace ProcessWire;
|
||||
|
||||
/**
|
||||
* Inputfield for icon selection
|
||||
*
|
||||
* @property bool $prefixValue Should value attribute always start with prefix? (externally)
|
||||
*
|
||||
*/
|
||||
class InputfieldIcon extends Inputfield {
|
||||
|
||||
public static function getModuleInfo() {
|
||||
@@ -68,7 +74,7 @@ class InputfieldIcon extends Inputfield {
|
||||
if($key == 'value') {
|
||||
$value = parent::getAttribute($key);
|
||||
if(empty($value)) return $value;
|
||||
if($this->prefixValue) {
|
||||
if($this->getSetting('prefixValue')) {
|
||||
if(strpos($value, self::prefix) !== 0) {
|
||||
// add prefix
|
||||
$value = self::prefix . $value;
|
||||
|
@@ -65,12 +65,12 @@ class InputfieldMarkup extends InputfieldWrapper {
|
||||
if($this->getSetting('entityEncodeText') !== false && $textFormat != Inputfield::textFormatNone) {
|
||||
if($textFormat == Inputfield::textFormatBasic) {
|
||||
$description = $this->entityEncode($description, Inputfield::textFormatBasic);
|
||||
$out = "\n<p class='description'>{$description}</p>$out";
|
||||
$out = "<p class='description'>{$description}</p>$out";
|
||||
} else if($textFormat == Inputfield::textFormatMarkdown) {
|
||||
$out = "\n<div class='description'>" . $this->entityEncode($description, Inputfield::textFormatMarkdown) . "</div>$out";
|
||||
$out = "<div class='description'>" . $this->entityEncode($description, Inputfield::textFormatMarkdown) . "</div>$out";
|
||||
}
|
||||
} else {
|
||||
$out = "\n<div class='description'>$description</div>$out";
|
||||
$out = "<div class='description'>$description</div>$out";
|
||||
}
|
||||
$this->description = ''; // prevents it from appearing again at the bottom
|
||||
}
|
||||
|
@@ -575,7 +575,7 @@ class InputfieldPage extends Inputfield implements ConfigurableModule {
|
||||
$inputfield->addClass($addClass);
|
||||
}
|
||||
|
||||
$out = "\n<div class='$class'>";
|
||||
$out = "<div class='$class'>";
|
||||
$out .= $inputfield->render();
|
||||
$out .= $this->renderAddable();
|
||||
|
||||
@@ -606,7 +606,7 @@ class InputfieldPage extends Inputfield implements ConfigurableModule {
|
||||
"value='$selector' />";
|
||||
}
|
||||
|
||||
$out .= "\n</div>";
|
||||
$out .= "</div>";
|
||||
|
||||
return $out;
|
||||
}
|
||||
@@ -657,14 +657,14 @@ class InputfieldPage extends Inputfield implements ConfigurableModule {
|
||||
$label ="<i class='fa fa-plus-circle'></i> " . $this->_('Create New');
|
||||
|
||||
$out =
|
||||
"\n<div class='InputfieldPageAdd'>" .
|
||||
"\n\t<p class='InputfieldPageAddButton'><a href='#'>$label</a></p>" .
|
||||
"\n\t<p class='InputfieldPageAddItems'>" .
|
||||
"\n\t\t<label class='description' for='$key'>$description</label>" .
|
||||
"\n\t\t$input" .
|
||||
"\n\t\t<span class='detail'>$notes</span>" .
|
||||
"\n\t</p>" .
|
||||
"\n</div>";
|
||||
"<div class='InputfieldPageAdd'>" .
|
||||
"<p class='InputfieldPageAddButton'><a href='#'>$label</a></p>" .
|
||||
"<p class='InputfieldPageAddItems'>" .
|
||||
"<label class='description' for='$key'>$description</label>" .
|
||||
"$input" .
|
||||
"<span class='detail'>$notes</span>" .
|
||||
"</p>" .
|
||||
"</div>";
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
@@ -105,7 +105,7 @@ class InputfieldPageAutocomplete extends Inputfield implements InputfieldHasArra
|
||||
if(strpos($label, '&') !== false) $label = $this->wire('sanitizer')->unentities($label);
|
||||
$label = $this->wire('sanitizer')->entities($label);
|
||||
$out =
|
||||
"\n<li class='ui-state-default$class'>" .
|
||||
"<li class='ui-state-default$class'>" .
|
||||
"<i class='fa fa-sort fa-fw'></i> " .
|
||||
"<span class='itemValue'>$value</span>" .
|
||||
"<span class='itemLabel'>$label</span> " .
|
||||
@@ -122,7 +122,7 @@ class InputfieldPageAutocomplete extends Inputfield implements InputfieldHasArra
|
||||
*/
|
||||
protected function ___renderList() {
|
||||
|
||||
$out = "\n<ol id='{$this->id}_items' data-id='{$this->id}' data-name='{$this->name}'>" .
|
||||
$out = "<ol id='{$this->id}_items' data-id='{$this->id}' data-name='{$this->name}'>" .
|
||||
$this->renderListItem("Label", "1", "itemTemplate");
|
||||
|
||||
foreach($this->value as $page_id) {
|
||||
@@ -135,7 +135,7 @@ class InputfieldPageAutocomplete extends Inputfield implements InputfieldHasArra
|
||||
$out .= $this->renderListItem($value, $page->id);
|
||||
}
|
||||
|
||||
$out .= "\n</ol>";
|
||||
$out .= "</ol>";
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
@@ -64,7 +64,7 @@ class InputfieldPageListSelect extends Inputfield implements InputfieldPageListS
|
||||
$attrs['data-cancel'] = $this->cancelLabel;
|
||||
$attrs['data-labelName'] = $this->attr('name');
|
||||
|
||||
$out = "\n<input type='text' " . $this->getAttributesString($attrs) . " />";
|
||||
$out = "<input type='text' " . $this->getAttributesString($attrs) . " />";
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ class InputfieldPageListSelectMultiple extends Inputfield implements InputfieldH
|
||||
protected function renderListItem($label, $value, $class = '') {
|
||||
if($class) $class = " $class";
|
||||
$out =
|
||||
"\n<li class='ui-state-default$class'>" .
|
||||
"<li class='ui-state-default$class'>" .
|
||||
// "<span class='ui-icon ui-icon-arrowthick-2-n-s'></span>" .
|
||||
"<i class='itemSort fa fa-sort'></i> " .
|
||||
"<span class='itemValue'>$value</span>" .
|
||||
@@ -73,7 +73,7 @@ class InputfieldPageListSelectMultiple extends Inputfield implements InputfieldH
|
||||
return "<p class='error'>" . $this->_('Unable to render this field due to missing parent page in field settings.') . '</p>';
|
||||
}
|
||||
|
||||
$out = "\n<ol id='{$this->id}_items'>" . $this->renderListItem("Label", "1", "itemTemplate");
|
||||
$out = "<ol id='{$this->id}_items'>" . $this->renderListItem("Label", "1", "itemTemplate");
|
||||
|
||||
foreach($this->value as $page_id) {
|
||||
$page = $this->pages->get((int) $page_id);
|
||||
@@ -83,7 +83,7 @@ class InputfieldPageListSelectMultiple extends Inputfield implements InputfieldH
|
||||
$out .= $this->renderListItem($label, $page->id);
|
||||
}
|
||||
|
||||
$out .= "\n</ol>";
|
||||
$out .= "</ol>";
|
||||
|
||||
$this->addClass('InputfieldPageListSelectMultipleData');
|
||||
$attrs = $this->getAttributes();
|
||||
@@ -100,7 +100,7 @@ class InputfieldPageListSelectMultiple extends Inputfield implements InputfieldH
|
||||
|
||||
$attrStr = $this->getAttributesString($attrs);
|
||||
$attrStr = "value='" . implode(',', $this->value) . "' $attrStr";
|
||||
$out .= "\n<input type='text' $attrStr />";
|
||||
$out .= "<input type='text' $attrStr />";
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@
|
||||
* @property string $checkboxName Leave blank to disable
|
||||
* @property string $checkboxLabel
|
||||
* @property string $checkboxValue
|
||||
* @property string $checkboxSuffix
|
||||
* @property bool $checkboxChecked
|
||||
*
|
||||
*/
|
||||
@@ -286,7 +287,6 @@ class InputfieldPageName extends InputfieldName implements ConfigurableModule {
|
||||
|
||||
if(is_array($data[$name])) {
|
||||
// data already in right save format, but need it to be a string for editing
|
||||
if(empty($replacements)) $replacements = self::$defaultReplacements;
|
||||
$replacements = self::replacementArrayToString($data[$name]);
|
||||
|
||||
} else {
|
||||
|
@@ -378,6 +378,7 @@ class InputfieldPageTable extends Inputfield {
|
||||
|
||||
if(isset($fields[$column])) {
|
||||
// custom
|
||||
/** @var Field $field */
|
||||
$field = $fields[$column];
|
||||
$v = $item->getFormatted($fieldName);
|
||||
if($field->type instanceof FieldtypeImage) {
|
||||
|
@@ -9,6 +9,8 @@
|
||||
*
|
||||
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
|
||||
* https://processwire.com
|
||||
*
|
||||
* @method void checkAjax()
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -123,7 +125,7 @@ class InputfieldPageTableAjax extends Wire {
|
||||
protected function sortItems(Page $page, Field $field, $sort) {
|
||||
|
||||
// if this field has it's own sort settings, then we have nothing to do here.
|
||||
if($field->sortfields && $field->sortfields != 'sort') return;
|
||||
if($field->get('sortfields') && $field->get('sortfields') != 'sort') return;
|
||||
|
||||
$value = $page->getUnformatted($field->name);
|
||||
if(!$value instanceof PageArray || !$value->count()) return;
|
||||
|
@@ -44,10 +44,10 @@ class InputfieldRadios extends InputfieldSelect {
|
||||
// don't bother setting a width, we will let them float where they want instead
|
||||
$ulClass = 'InputfieldRadiosFloated';
|
||||
}
|
||||
$out = "\n\t<ul class='$ulClass pw-clearfix ui-helper-clearfix'>";
|
||||
$out = "<ul class='$ulClass pw-clearfix ui-helper-clearfix'>";
|
||||
|
||||
} else {
|
||||
$out = "\n\t<ul class='InputfieldRadiosStacked'>";
|
||||
$out = "<ul class='InputfieldRadiosStacked'>";
|
||||
}
|
||||
|
||||
foreach($options as $key => $value) {
|
||||
@@ -69,7 +69,7 @@ class InputfieldRadios extends InputfieldSelect {
|
||||
$label = "<span class='$textClass'>$label</span>";
|
||||
|
||||
$out .=
|
||||
"\n\t\t<li$liAttr><label$attrs>" .
|
||||
"<li$liAttr><label$attrs>" .
|
||||
"<input$checked$disabled " .
|
||||
"type='radio' " .
|
||||
"name='{$this->name}' " .
|
||||
@@ -79,7 +79,7 @@ class InputfieldRadios extends InputfieldSelect {
|
||||
"</label></li>";
|
||||
}
|
||||
|
||||
$out .= "\n\t</ul>";
|
||||
$out .= "</ul>";
|
||||
|
||||
return $out;
|
||||
}
|
||||
@@ -95,6 +95,7 @@ class InputfieldRadios extends InputfieldSelect {
|
||||
|
||||
public function ___getConfigInputfields() {
|
||||
$inputfields = parent::___getConfigInputfields();
|
||||
/** @var InputfieldInteger $f */
|
||||
$f = $this->wire('modules')->get('InputfieldInteger');
|
||||
$f->label = $this->_('Columns of Radio Buttons');
|
||||
$f->description = $this->_('If you want the radio buttons to display in columns (rather than stacked), enter the number of columns you want to use (up to 10). To display buttons side-by-side (inline) enter 1.');
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* Sublcasses will want to override the render method, but it's not necessary to override processInput().
|
||||
* Subclasses that select multiple values should implement the InputfieldHasArrayValue interface.
|
||||
*
|
||||
* @todo add support for 'required' attribute?
|
||||
* @property string|int $defaultValue
|
||||
*
|
||||
*/
|
||||
class InputfieldSelect extends Inputfield {
|
||||
@@ -51,7 +51,8 @@ class InputfieldSelect extends Inputfield {
|
||||
*
|
||||
* @param string $value Value that the option submits
|
||||
* @param string $label|array Optional label associated with the value (if null, value will be used as the label)
|
||||
* @param array $attributes Optional attributes to be associated with this option (i.e. a 'selected' attribute for an <option> tag)
|
||||
* @param array $attributes Optional attributes to be associated with this option (i.e. a 'selected' attribute for
|
||||
* an <option> tag)
|
||||
* @return $this
|
||||
*
|
||||
*/
|
||||
@@ -65,8 +66,9 @@ class InputfieldSelect extends Inputfield {
|
||||
/**
|
||||
* Add multiple options at once
|
||||
*
|
||||
* @param array $options May be associative or regular array. If associative, use $value => $label. If regular, use just array($value, ...)
|
||||
* @return this
|
||||
* @param array $options May be associative or regular array. If associative, use $value => $label. If regular,
|
||||
* use just array($value, ...)
|
||||
* @return $this
|
||||
*
|
||||
*/
|
||||
public function addOptions(array $options) {
|
||||
@@ -83,7 +85,7 @@ class InputfieldSelect extends Inputfield {
|
||||
* Lines with an equals sign are split into separate value and label, i.e. value=label
|
||||
*
|
||||
* @param string $value
|
||||
* @return this
|
||||
* @return $this
|
||||
*
|
||||
*/
|
||||
public function addOptionsString($value) {
|
||||
@@ -141,6 +143,9 @@ class InputfieldSelect extends Inputfield {
|
||||
|
||||
/**
|
||||
* Remove the option with the given value
|
||||
*
|
||||
* @param string|int $value
|
||||
* @return $this
|
||||
*
|
||||
*/
|
||||
public function removeOption($value) {
|
||||
@@ -191,6 +196,9 @@ class InputfieldSelect extends Inputfield {
|
||||
|
||||
/**
|
||||
* Returns whether the provided value is selected
|
||||
*
|
||||
* @param string|int $value
|
||||
* @return bool
|
||||
*
|
||||
*/
|
||||
public function isOptionSelected($value) {
|
||||
@@ -208,14 +216,21 @@ class InputfieldSelect extends Inputfield {
|
||||
}
|
||||
|
||||
if($this instanceof InputfieldHasArrayValue) {
|
||||
// if(is_array($this->attr('value'))) {
|
||||
// multiple selection
|
||||
/** @var InputfieldSelect $this */
|
||||
return in_array($value, $this->attr('value'));
|
||||
}
|
||||
|
||||
return "$value" == (string) $this->value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is the given option value disabled?
|
||||
*
|
||||
* @param $value
|
||||
* @return bool
|
||||
*
|
||||
*/
|
||||
public function isOptionDisabled($value) {
|
||||
$disabled = false;
|
||||
if(isset($this->optionAttributes[$value])) {
|
||||
@@ -225,26 +240,40 @@ class InputfieldSelect extends Inputfield {
|
||||
return $disabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the given options
|
||||
*
|
||||
* @param array $options
|
||||
* @param bool $allowBlank
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
protected function renderOptions($options, $allowBlank = true) {
|
||||
|
||||
$out = '';
|
||||
reset($options);
|
||||
$key = key($options);
|
||||
$hasBlankOption = empty($key);
|
||||
if($allowBlank && !$this->required && !$this->attr('multiple') && !$hasBlankOption) $out .= "<option value=''> </option>";
|
||||
if($allowBlank && !$this->required && !$this->attr('multiple') && !$hasBlankOption) {
|
||||
$out .= "<option value=''> </option>";
|
||||
}
|
||||
|
||||
foreach($options as $value => $label) {
|
||||
|
||||
if(is_array($label)) {
|
||||
$out .= "\n\t<optgroup label='" . htmlspecialchars($value, ENT_QUOTES, 'UTF-8') . "'>" .
|
||||
$out .=
|
||||
"<optgroup label='" . htmlspecialchars($value, ENT_QUOTES, 'UTF-8') . "'>" .
|
||||
$this->renderOptions($label, false) .
|
||||
"\n\t</optgroup>";
|
||||
"</optgroup>";
|
||||
continue;
|
||||
}
|
||||
|
||||
$selected = $this->isOptionSelected($value) ? " selected='selected'" : '';
|
||||
$attrs = $this->getOptionAttributesString($value);
|
||||
$out .= "\n\t<option$selected $attrs value='" . htmlspecialchars($value, ENT_QUOTES, "UTF-8") . "'>" . $this->entityEncode($label) . "</option>";
|
||||
$out .=
|
||||
"<option$selected $attrs value='" . htmlspecialchars($value, ENT_QUOTES, "UTF-8") . "'>" .
|
||||
$this->entityEncode($label) .
|
||||
"</option>";
|
||||
}
|
||||
|
||||
return $out;
|
||||
@@ -262,6 +291,7 @@ class InputfieldSelect extends Inputfield {
|
||||
|
||||
// when a value is required and the value is empty and a default value is specified, we use it.
|
||||
if($this instanceof InputfieldHasArrayValue) {
|
||||
/** @var InputfieldSelect $this */
|
||||
$value = explode("\n", $this->defaultValue);
|
||||
foreach($value as $k => $v) {
|
||||
$value[$k] = trim($v); // remove possible extra LF
|
||||
@@ -277,6 +307,8 @@ class InputfieldSelect extends Inputfield {
|
||||
|
||||
/**
|
||||
* Render and return the output for this Select
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function ___render() {
|
||||
@@ -285,13 +317,19 @@ class InputfieldSelect extends Inputfield {
|
||||
unset($attrs['value']);
|
||||
|
||||
$out =
|
||||
"\n<select " . $this->getAttributesString($attrs) . ">" .
|
||||
"<select " . $this->getAttributesString($attrs) . ">" .
|
||||
$this->renderOptions($this->options) .
|
||||
"\n</select>";
|
||||
"</select>";
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render non-editable value
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function ___renderValue() {
|
||||
|
||||
$out = '';
|
||||
@@ -315,7 +353,7 @@ class InputfieldSelect extends Inputfield {
|
||||
}
|
||||
}
|
||||
|
||||
if(strlen($out)) $out = "<ul>$out</ul>";
|
||||
if(strlen($out)) $out = "<ul class='pw-bullets'>$out</ul>";
|
||||
|
||||
return $out;
|
||||
}
|
||||
@@ -335,8 +373,8 @@ class InputfieldSelect extends Inputfield {
|
||||
/**
|
||||
* Get an attributes string intended for the <option> element
|
||||
*
|
||||
* @param string|array $key If an array, it will be assumed to the attributes you want rendered. If a key for an existing option, then
|
||||
* the attributes for that option will be rendered.
|
||||
* @param string|array $key If an array, it will be assumed to the attributes you want rendered. If a key for an
|
||||
* existing option, then the attributes for that option will be rendered.
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
@@ -376,6 +414,7 @@ class InputfieldSelect extends Inputfield {
|
||||
$value = $this->attr('value');
|
||||
|
||||
if($this instanceof InputfieldHasArrayValue) {
|
||||
/** @var InputfieldSelect $this */
|
||||
foreach($value as $k => $v) {
|
||||
if(!$this->isOption($v)) {
|
||||
// $this->message("Removing invalid option: " . wire('sanitizer')->entities($value[$k]), Notice::debug);
|
||||
@@ -393,12 +432,27 @@ class InputfieldSelect extends Inputfield {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get property
|
||||
*
|
||||
* @param string $key
|
||||
* @return array|mixed|null
|
||||
*
|
||||
*/
|
||||
public function get($key) {
|
||||
if($key == 'options') return $this->options;
|
||||
if($key == 'optionAttributes') return $this->optionAttributes;
|
||||
return parent::get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return $this
|
||||
*
|
||||
*/
|
||||
public function set($key, $value) {
|
||||
|
||||
if($key == 'options') {
|
||||
@@ -407,10 +461,17 @@ class InputfieldSelect extends Inputfield {
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
return parent::set($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set attribute
|
||||
*
|
||||
* @param array|string $key
|
||||
* @param array|int|string $value
|
||||
* @return $this
|
||||
*
|
||||
*/
|
||||
public function setAttribute($key, $value) {
|
||||
if($key == 'value') {
|
||||
if(is_object($value) || (is_string($value) && strpos($value, '|'))) {
|
||||
@@ -429,6 +490,12 @@ class InputfieldSelect extends Inputfield {
|
||||
return parent::setAttribute($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the value empty?
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
*/
|
||||
public function isEmpty() {
|
||||
$value = $this->attr('value');
|
||||
|
||||
@@ -447,9 +514,16 @@ class InputfieldSelect extends Inputfield {
|
||||
} else {
|
||||
return strlen($value) === 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Field configuration
|
||||
*
|
||||
* @return InputfieldWrapper
|
||||
*
|
||||
*/
|
||||
public function ___getConfigInputfields() {
|
||||
|
||||
$inputfields = parent::___getConfigInputfields();
|
||||
@@ -474,7 +548,6 @@ class InputfieldSelect extends Inputfield {
|
||||
$f = $this->wire('modules')->get('InputfieldTextarea');
|
||||
$f->attr('name', 'options');
|
||||
$value = '';
|
||||
$options = array();
|
||||
foreach($this->options as $key => $option) {
|
||||
if(is_array($option)) {
|
||||
$value .= "$key\n";
|
||||
|
@@ -9,6 +9,7 @@
|
||||
*
|
||||
* @property bool $header Whether or not button will also appear in header.
|
||||
* @property bool $secondary Whether or not button is secondary.
|
||||
* @property string $dropdownInputName #pw-internal
|
||||
*
|
||||
*/
|
||||
class InputfieldSubmit extends Inputfield {
|
||||
@@ -143,7 +144,6 @@ class InputfieldSubmit extends Inputfield {
|
||||
$config->scripts->add($config->urls->InputfieldSubmit . $file);
|
||||
$numValues = 0;
|
||||
$dropdownID = $this->attr('id') . '_dropdown';
|
||||
$out = '';
|
||||
$out = "<ul id='$dropdownID' class='pw-button-dropdown' data-my='left top' data-at='left bottom+1'>";
|
||||
|
||||
foreach($this->dropdownItems as $item) {
|
||||
@@ -179,7 +179,7 @@ class InputfieldSubmit extends Inputfield {
|
||||
}
|
||||
|
||||
// script to initialize this dropdown immediately
|
||||
$out .= "<script>InputfieldSubmitDropdown.init('#{$this->id}')</script>";
|
||||
$out .= "<script" . ">InputfieldSubmitDropdown.init('#{$this->id}')</script>";
|
||||
|
||||
return $out;
|
||||
}
|
||||
@@ -199,7 +199,7 @@ class InputfieldSubmit extends Inputfield {
|
||||
/**
|
||||
* Add a dropdown item to this button
|
||||
*
|
||||
* @param string string $type Either 'link' or 'value'
|
||||
* @param string $type Either 'link' or 'value'
|
||||
* @param string|int $value
|
||||
* @param string $label
|
||||
* @param string $icon
|
||||
|
@@ -110,7 +110,7 @@ class InputfieldText extends Inputfield {
|
||||
*/
|
||||
public function ___render() {
|
||||
$attrStr = $this->getAttributesString();
|
||||
$out = "\n<input $attrStr />";
|
||||
$out = "<input $attrStr />";
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
@@ -87,7 +87,7 @@ class InputfieldTextarea extends InputfieldText {
|
||||
$attrs = $this->getAttributes();
|
||||
unset($attrs['value'], $attrs['size'], $attrs['type']);
|
||||
|
||||
$out = "\n" .
|
||||
$out =
|
||||
"<textarea " . $this->getAttributesString($attrs) . ">" .
|
||||
htmlspecialchars($this->value, ENT_QUOTES, "UTF-8") .
|
||||
"</textarea>";
|
||||
|
Reference in New Issue
Block a user