Completed
Push — master ( aec9f9...84751c )
by Sam
02:36 queued 01:13
created

FormHelper::cancelButton()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * Contains common helper functions needed for forms
5
 *
6
 * @author Sam Stenvall <[email protected]>
7
 * @copyright Copyright &copy; Sam Stenvall 2013-
8
 * @license https://www.gnu.org/licenses/gpl.html The GNU General Public License v3.0
9
 */
10
class FormHelper
11
{
12
13
	/**
14
	 * Genereates a cancel button that links to the specified URL
15
	 * @param mixed $url the button URL
16
	 * @return string the HTML for the button
17
	 */
18
	public static function cancelButton($url)
19
	{
20
		return TbHtml::linkButton(Yii::t('Forms', 'Cancel'), array(
21
			'url'=>$url,
22
			'color'=>TbHtml::BUTTON_COLOR_INFO,
23
			'class'=>'btn-padded',
24
		));
25
	}
26
27
	/**
28
	 * Generates a nicely formatted help block, useful to explain what a form or 
29
	 * a page does. Nothing is rendered if the "showHelpBlocks" setting is set 
30
	 * to false.
31
	 * @param string $content the block content
32
	 * @return string the HTML for the help block
33
	 */
34
	public static function helpBlock($content)
35
	{
36
		if (!Setting::getBoolean('showHelpBlocks'))
37
			return;
38
		
39
		$output  = CHtml::openTag('p', array('class'=>'form-help'));
40
		$output .= TbHtml::icon(TbHtml::ICON_EXCLAMATION_SIGN);
41
		$output .= $content;
42
		$output .= CHtml::closeTag('p');
43
		
44
		return $output;
45
	}
46
47
}