: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace Nextend\Framework\Form;
use Nextend\Framework\Asset\Js\Js;
use Nextend\Framework\Form\Insert\AbstractInsert;
use Nextend\Framework\Sanitize;
use Nextend\Framework\View\Html;
abstract class AbstractField implements ContainedInterface {
private $previous, $next;
public function getPrevious() {
* @param AbstractField|null $element
public function setPrevious($element = null) {
$this->previous = $element;
public function getNext() {
* @param AbstractField|null $element
public function setNext($element = null) {
$element->setPrevious($this);
public function remove() {
protected $controlName = '';
private $exposeName = true;
protected $tipLabel = '';
protected $tipDescription = '';
protected $rowClass = '';
protected $rowAttributes = array();
protected $relatedFields = array();
protected $relatedFieldsOff = array();
* AbstractField constructor.
* @param TraitFieldset|AbstractInsert $insertAt
* @param array $parameters
public function __construct($insertAt, $name = '', $label = '', $default = '', $parameters = array()) {
if ($insertAt instanceof ContainerInterface) {
$this->parent = $insertAt;
$this->parent->addElement($this);
} else if ($insertAt instanceof AbstractInsert) {
$this->parent = $insertAt->insert($this);
$this->controlName = $this->parent->getControlName();
$this->fieldID = $this->generateId($this->controlName . $this->name);
$this->defaultValue = $default;
foreach ($parameters as $option => $value) {
$option = 'set' . $option;
$this->{$option}($value);
public function getID() {
public function setDefaultValue($defaultValue) {
$this->defaultValue = $defaultValue;
public function setExposeName($exposeName) {
$this->exposeName = $exposeName;
public function getPost() {
public function setPost($post) {
public function setTip($tip) {
* @param string $tipLabel
public function setTipLabel($tipLabel) {
$this->tipLabel = $tipLabel;
* @param string $tipDescription
public function setTipDescription($tipDescription) {
$this->tipDescription = $tipDescription;
public function setTipLink($tipLink) {
$this->tipLink = $tipLink;
public function setRowClass($rowClass) {
$this->rowClass .= $rowClass;
public function getRowClass() {
public function getClass() {
public function setClass($class) {
protected function getFieldName() {
return $this->controlName . '[' . $this->name . ']';
public function render() {
public function displayLabel() {
echo wp_kses($this->fetchTooltip(), Sanitize::$adminFormTags);
public function displayElement() {
echo wp_kses($this->fetchElement(), Sanitize::$adminFormTags);
protected function fetchTooltip() {
if ($this->label === false || $this->label === '') {
if (!empty($this->tipDescription)) {
'class' => 'ssi_16 ssi_16--info',
'data-tip-description' => $this->tipDescription
if (!empty($this->tipLabel)) {
$tipAttributes['data-tip-label'] = $this->tipLabel;
if (!empty($this->tipLink)) {
$tipAttributes['data-tip-link'] = $this->tipLink;
$post .= Html::tag('i', $tipAttributes);
return Html::tag('label', $attributes, $this->label) . $post;
protected function fetchNoTooltip() {
abstract protected function fetchElement();
public function getValue() {
->get($this->name, $this->defaultValue);
public function setValue($value) {
->set($this->name, $value);
* @param array $rowAttributes
public function setRowAttributes($rowAttributes) {
$this->rowAttributes = $rowAttributes;
public function getRowAttributes() {
return $this->rowAttributes;
public function setStyle($style) {
protected function getStyle() {
* @param string $relatedFields
public function setRelatedFields($relatedFields) {
$this->relatedFields = $relatedFields;
public function setRelatedFieldsOff($relatedFieldsOff) {
$this->relatedFieldsOff = $relatedFieldsOff;
protected function renderRelatedFields() {
if (!empty($this->relatedFields) || !empty($this->relatedFieldsOff)) {
'relatedFieldsOn' => $this->relatedFields,
'relatedFieldsOff' => $this->relatedFieldsOff
Js::addInline('new _N2.FormRelatedFields("' . $this->fieldID . '", ' . json_encode($options) . ');');
protected function generateId($name) {
return str_replace(array(
public function getLabelClass() {
if ($this->label === false) {
return 'n2_field--label-none';
} else if ($this->label === '') {
return 'n2_field--label-placeholder';
public function hasLabel() {
return !empty($this->label);
public function getName() {
public function getForm() {
return $this->parent->getForm();
public function getControlName() {
return $this->controlName;
* @param string $controlName
public function setControlName($controlName) {
$this->controlName = $controlName;
public function getParent() {
public function getPath() {
return $this->parent->getPath() . '/' . $this->name;