# contact-forms/1.9.2/PFBC/Element/Button.php

Contact Forms by Cimatti, version 1.9.2. 39 lines.

- Page: https://pluginprobe.com/plugins/contact-forms/1.9.2/code/PFBC/Element/Button.php
- Raw: https://pluginprobe.com/plugins/contact-forms/1.9.2/raw/PFBC/Element/Button.php
- Modified: 2023-03-14T12:04:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/contact-forms/1.9.2/code/PFBC/Element/Button.php#L10-L20`.

```php
<?php
class Element_Button extends Element {
	protected $attributes = array("type" => "submit", "value" => "Submit");
	protected $icon;

	public function __construct($label = "Submit", $type = "", array $properties = null) {
		if(!is_array($properties))
			$properties = array();

		if(!empty($type))
			$properties["type"] = $type;
		
		if(empty($properties["value"]))
			$properties["value"] = $label;
			
		parent::__construct($label, "", $properties);
	}

	public function jQueryDocumentReady() {
		/*Unless explicitly prevented, jQueryUI's button widget functionality is applied to 
		the each Button element.*/
		if(!in_array("jQueryUIButtons", $this->form->getPrevent())) {
			echo 'jQuery("#', $this->attributes["id"], '").button(';
			/*Any of the jQueryUI framework icons can be added to your buttons via the icon 
			property.  See http://jqueryui.com/themeroller/ for a complete list of available
			icons.*/
			if(!empty($this->icon))
				echo '{ icons: { primary: "ui-icon-', $this->icon, '" } }';
			echo ');';
		}
	}

	public function render() {
		/*The button tag is used instead of input b/c it functions better with jQueryUI's 
		button widget - specifically the icon option.*/
		echo '<button', $this->getAttributes(), '>', $this->label, '</button>';
	}	
}

```
