Skip to content

Commit

Permalink
Dev: review HTML for SettingWidget
Browse files Browse the repository at this point in the history
Dev: a list of setting goes in same fieldset and are a list
Dev: fix issue : legend without fieldset
  • Loading branch information
Shnoulle committed Apr 1, 2015
1 parent fda369e commit 88f3e54
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 36 deletions.
42 changes: 12 additions & 30 deletions application/extensions/SettingsWidget/SettingsWidget.php
Expand Up @@ -17,27 +17,25 @@ class SettingsWidget extends CWidget
*/
public $form = true;
public $formHtmlOptions = array();
public $fieldHtmlOptions = array();

public $method = 'post';
public $prefix;
public $settings = array();
/**
* Set to true to render elements in a lit (ul/li)
* @var boolean
*/
public $inlist=false;
public $title;


public $title;
public $inlist=true;// Leave before removing
public function beginForm()
{
if ($this->form)
{
echo CHtml::beginForm($this->action, $this->method, $this->formHtmlOptions);
echo CHtml::beginForm($this->action, $this->method,$this->formHtmlOptions);
}
else
{
echo CHtml::openTag('div', array('class' => $this->formHtmlOptions['class'], 'id' => $this->getId()));
$this->fieldHtmlOptions=array_replace($this->formHtmlOptions,$this->fieldHtmlOptions);
}
echo CHtml::openTag('fieldset', array_replace($this->fieldHtmlOptions, array('id' => $this->getId())));
if (isset($this->title))
{
echo CHtml::tag('legend', array(), $this->title);
Expand All @@ -46,14 +44,11 @@ public function beginForm()

public function endForm()
{
echo CHtml::closeTag('fieldset');
if ($this->form)
{
echo CHtml::endForm();
}
else
{
echo CHtml::closeTag('div');
}
}
public function init() {
parent::init();
Expand Down Expand Up @@ -88,7 +83,7 @@ protected function renderButton($label, $metaData)
$metaData['class'][]='btn-link';
$metaData['class'][]='button';
}
$htmlOptions = $this->htmlOptions($metaData,null,array('container'=> false, 'separator' => ''));
$htmlOptions = $this->htmlOptions($metaData);

if (isset($metaData['type']) && $metaData['type'] == 'link')
{
Expand Down Expand Up @@ -169,25 +164,12 @@ protected function renderSetting($name, $metaData, $form = null, $return = false

protected function renderSettings()
{
if($this->inlist)
{
echo CHtml::openTag('ul');
}
echo CHtml::openTag('ul',array('class'=>"settings-list"));
foreach($this->settings as $name => $metaData)
{
if($this->inlist)
{
$this->renderSetting($name, $metaData, null, false,'li');
}
else
{
$this->renderSetting($name, $metaData);
}
}
if($this->inlist)
{
echo CHtml::closeTag('ul');
$this->renderSetting($name, $metaData, null, false,'li');
}
echo CHtml::closeTag('ul');
}


Expand Down
10 changes: 8 additions & 2 deletions application/extensions/SettingsWidget/assets/settingswidget.css
Expand Up @@ -9,12 +9,18 @@
.settingswidget {
margin: 0 1em;
}
.settingswidget > ul{
ul.settings-list{
margin:0;padding:0;
}
.settingswidget > ul > li{
ul.settings-list > li
{
list-style: none;
}
fieldset.settingswidget, form.settingswidget > fieldset {
border:0;
padding:0;
margin:0;
}
.form-horizontal .control-label,.form-horizontal .controls{
-moz-box-sizing: border-box;
box-sizing: border-box;
Expand Down
Expand Up @@ -9,12 +9,11 @@

$this->widget('ext.SettingsWidget.SettingsWidget', array(
'id'=>'general',
//'title'=>gt("General"),
'title'=>gt("General"),
'form' => false,
'formHtmlOptions'=>array(
'class'=>'form-core',
),
'inlist'=>true,
'settings' => array(
# 'baselanguage'=>array(
# 'type'=>'info',
Expand Down
Expand Up @@ -127,12 +127,11 @@
/* Presentation & navigation settings */
$this->widget('ext.SettingsWidget.SettingsWidget', array(
'id'=>'presentation',
//'title'=>gT("Presentation & navigation");,
'title'=>gT("Presentation & navigation");,
'form' => false,
'formHtmlOptions'=>array(
'class'=>'form-core',
),
'inlist'=>true,
'settings' => array(
'format'=>array(
'type'=>'select',
Expand Down

0 comments on commit 88f3e54

Please sign in to comment.