|
@@ 787-806 (lines=20) @@
|
| 784 |
|
* @since 1.0 |
| 785 |
|
* @throws \UnexpectedValueException |
| 786 |
|
*/ |
| 787 |
|
public function removeField($name, $group = null) |
| 788 |
|
{ |
| 789 |
|
// Make sure there is a valid Form XML document. |
| 790 |
|
if (!($this->xml instanceof \SimpleXMLElement)) |
| 791 |
|
{ |
| 792 |
|
throw new \UnexpectedValueException(sprintf('%s::getFieldAttribute `xml` is not an instance of SimpleXMLElement', get_class($this))); |
| 793 |
|
} |
| 794 |
|
|
| 795 |
|
// Find the form field element from the definition. |
| 796 |
|
$element = $this->findField($name, $group); |
| 797 |
|
|
| 798 |
|
// If the element exists remove it from the form definition. |
| 799 |
|
if ($element instanceof \SimpleXMLElement) |
| 800 |
|
{ |
| 801 |
|
$dom = dom_import_simplexml($element); |
| 802 |
|
$dom->parentNode->removeChild($dom); |
| 803 |
|
} |
| 804 |
|
|
| 805 |
|
return true; |
| 806 |
|
} |
| 807 |
|
|
| 808 |
|
/** |
| 809 |
|
* Method to remove a group from the form definition. |
|
@@ 936-962 (lines=27) @@
|
| 933 |
|
* @since 1.0 |
| 934 |
|
* @throws \UnexpectedValueException |
| 935 |
|
*/ |
| 936 |
|
public function setFieldAttribute($name, $attribute, $value, $group = null) |
| 937 |
|
{ |
| 938 |
|
// Make sure there is a valid Form XML document. |
| 939 |
|
if (!($this->xml instanceof \SimpleXMLElement)) |
| 940 |
|
{ |
| 941 |
|
throw new \UnexpectedValueException(sprintf('%s::getFieldAttribute `xml` is not an instance of SimpleXMLElement', get_class($this))); |
| 942 |
|
} |
| 943 |
|
|
| 944 |
|
// Find the form field element from the definition. |
| 945 |
|
$element = $this->findField($name, $group); |
| 946 |
|
|
| 947 |
|
// If the element doesn't exist return false. |
| 948 |
|
if (!($element instanceof \SimpleXMLElement)) |
| 949 |
|
{ |
| 950 |
|
return false; |
| 951 |
|
} |
| 952 |
|
else |
| 953 |
|
// Otherwise set the attribute and return true. |
| 954 |
|
{ |
| 955 |
|
$element[$attribute] = $value; |
| 956 |
|
|
| 957 |
|
// Synchronize any paths found in the load. |
| 958 |
|
$this->syncPaths(); |
| 959 |
|
|
| 960 |
|
return true; |
| 961 |
|
} |
| 962 |
|
} |
| 963 |
|
|
| 964 |
|
/** |
| 965 |
|
* Method to set some field XML elements to the form definition. If the replace flag is set then |