PropertyModifierSubstring: fix erraneous form fields

This commit is contained in:
Thomas Gelf 2016-03-05 17:04:13 +01:00
parent d0250dc312
commit d7da41b789

View File

@ -9,19 +9,25 @@ class PropertyModifierSubstring extends PropertyModifierHook
{ {
public static function addSettingsFormFields(QuickForm $form) public static function addSettingsFormFields(QuickForm $form)
{ {
$form->addElement('text', 'pattern', array( $form->addElement('text', 'start', array(
'label' => 'Regex pattern', 'label' => 'Start',
'required' => true, 'required' => true,
'description' => sprintf(
$form->translate(
'Please see %s for detailled instructions of how start and and work'
),
'http://php.net/manual/en/function.substr.php'
)
)); ));
$form->addElement('text', 'replacement', array( $form->addElement('text', 'length', array(
'label' => 'Replacement', 'label' => 'End',
'required' => true, 'required' => true,
)); ));
} }
public function transform($value) public function transform($value)
{ {
return substr($value, $this->settings['start'], $this->settings['end'] - $this->settings['start']); return substr($value, $this->getSetting('start'), $this->getSetting('length'));
} }
} }