Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
Yii Bootstrap 3
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Common
Yii Bootstrap 3
Commits
377fe8c2
Commit
377fe8c2
authored
May 12, 2014
by
TTouka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated TbActiveForm
parent
56c62171
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
37 deletions
+57
-37
_tabular.php
demo/protected/views/site/_tabular.php
+2
-3
index.php
demo/protected/views/site/index.php
+19
-11
TbActiveForm.php
widgets/TbActiveForm.php
+16
-2
TbInput.php
widgets/input/TbInput.php
+7
-8
TbInputHorizontal.php
widgets/input/TbInputHorizontal.php
+13
-13
No files found.
demo/protected/views/site/_tabular.php
View file @
377fe8c2
...
...
@@ -3,11 +3,11 @@
<legend>
<?php
echo
CHtml
::
encode
(
$language
);
?>
translation
</legend>
<?php
echo
$form
->
textFieldRow
(
$model
,
"[
{
$locale
}
]textField"
);
?>
<?php
echo
$form
->
textAreaRow
(
$model
,
"[
{
$locale
}
]textarea"
,
array
(
'
class'
=>
'span8'
,
'
rows'
=>
8
));
?>
<?php
echo
$form
->
textAreaRow
(
$model
,
"[
{
$locale
}
]textarea"
,
array
(
'rows'
=>
8
));
?>
<?php
echo
$form
->
checkBoxListRow
(
$model
,
"[
{
$locale
}
]checkboxes"
,
array
(
'Option one is this and that—be sure to include why it\'s great'
,
'Option two can also be checked and included in form results'
,
'Option three can—yes, you guessed it—also be checked and included in form results'
,
),
array
(
'hint'
=>
'<strong>Note:</strong> Labels surround all the options for much larger click areas.'
));
?>
</fieldset>
\ No newline at end of file
</fieldset>
demo/protected/views/site/index.php
View file @
377fe8c2
...
...
@@ -994,8 +994,8 @@ Yii::app()->clientScript->registerScript('siteIndex', "
'htmlOptions'
=>
array
(
'class'
=>
'well'
),
));
?>
<?php
echo
$form
->
textFieldRow
(
$model
,
'textField'
,
array
(
'class'
=>
'col-md-3'
)
);
?>
<?php
echo
$form
->
passwordFieldRow
(
$model
,
'password'
,
array
(
'class'
=>
'col-md-3'
)
);
?>
<?php
echo
$form
->
textFieldRow
(
$model
,
'textField'
);
?>
<?php
echo
$form
->
passwordFieldRow
(
$model
,
'password'
);
?>
<?php
echo
$form
->
checkboxRow
(
$model
,
'checkbox'
);
?>
<?php
$this
->
widget
(
'bootstrap.widgets.TbButton'
,
array
(
'buttonType'
=>
'submit'
,
'label'
=>
'Login'
));
?>
...
...
@@ -1009,8 +1009,8 @@ Yii::app()->clientScript->registerScript('siteIndex', "
'htmlOptions'=>array('class'=>'well'),
)); ?>
<?php echo
\$
form->textFieldRow(
\$
model, 'textField'
, array('class'=>'col-md-3')
); ?>
<?php echo
\$
form->passwordFieldRow(
\$
model, 'password'
, array('class'=>'col-md-3')
); ?>
<?php echo
\$
form->textFieldRow(
\$
model, 'textField'); ?>
<?php echo
\$
form->passwordFieldRow(
\$
model, 'password'); ?>
<?php echo
\$
form->checkboxRow(
\$
model, 'checkbox'); ?>
<?php
\$
this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'submit', 'label'=>'Login')); ?>
...
...
@@ -1025,7 +1025,7 @@ Yii::app()->clientScript->registerScript('siteIndex', "
'htmlOptions'
=>
array
(
'class'
=>
'well'
),
));
?>
<?php
echo
$form
->
textFieldRow
(
$model
,
'textField'
,
array
(
'class'
=>
'input-medium'
,
'prepend'
=>
'<i class="icon-search"></i>'
));
?>
<?php
echo
$form
->
textFieldRow
(
$model
,
'textField'
,
array
(
'class'
=>
'input-medium'
,
'prepend'
=>
'<i class="
glyphicon glyph
icon-search"></i>'
));
?>
<?php
$this
->
widget
(
'bootstrap.widgets.TbButton'
,
array
(
'buttonType'
=>
'submit'
,
'label'
=>
'Go'
));
?>
<?php
$this
->
endWidget
();
?>
...
...
@@ -1039,7 +1039,7 @@ Yii::app()->clientScript->registerScript('siteIndex', "
'htmlOptions'=>array('class'=>'well'),
)); ?>
<?php echo
\$
form->textFieldRow(
\$
model, 'textField', array('class'=>'input-medium', 'prepend'=>'<i class=
\"
icon-search
\"
></i>')); ?>
<?php echo
\$
form->textFieldRow(
\$
model, 'textField', array('class'=>'input-medium', 'prepend'=>'<i class=
\"
glyphicon glyph
icon-search
\"
></i>')); ?>
<?php
\$
this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'submit', 'label'=>'Go')); ?>
<?php
\$
this->endWidget(); ?>"
);
?>
...
...
@@ -1112,9 +1112,11 @@ Yii::app()->clientScript->registerScript('siteIndex', "
</fieldset>
<div
class=
"form-actions"
>
<div
class=
"form-group"
>
<div
class=
"col-sm-offset-2 col-sm-10"
>
<?php
$this
->
widget
(
'bootstrap.widgets.TbButton'
,
array
(
'buttonType'
=>
'submit'
,
'type'
=>
'primary'
,
'label'
=>
'Submit'
));
?>
<?php
$this
->
widget
(
'bootstrap.widgets.TbButton'
,
array
(
'buttonType'
=>
'reset'
,
'label'
=>
'Reset'
));
?>
</div>
</div>
<?php
$this
->
endWidget
();
?>
...
...
@@ -1155,9 +1157,11 @@ Yii::app()->clientScript->registerScript('siteIndex', "
</fieldset>
<div class=
\"
form-actions
\"
>
<div class=
\"
form-group
\"
>
<div class=
\"
col-sm-offset-2 col-sm-10
\"
>
<?php
\$
this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'submit', 'type'=>'primary', 'label'=>'Submit')); ?>
<?php
\$
this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'reset', 'label'=>'Reset')); ?>
</div>
</div>
<?php
\$
this->endWidget(); ?>"
);
?>
...
...
@@ -1174,9 +1178,11 @@ Yii::app()->clientScript->registerScript('siteIndex', "
'tabs'
=>
$this
->
getTabularFormTabs
(
$form
,
$model
),
));
?>
<div
class=
"form-actions"
>
<div
class=
"form-group"
>
<div
class=
"col-sm-offset-2 col-sm-10"
>
<?php
$this
->
widget
(
'bootstrap.widgets.TbButton'
,
array
(
'buttonType'
=>
'submit'
,
'type'
=>
'primary'
,
'label'
=>
'Submit'
));
?>
<?php
$this
->
widget
(
'bootstrap.widgets.TbButton'
,
array
(
'buttonType'
=>
'reset'
,
'label'
=>
'Reset'
));
?>
</div>
</div>
<?php
$this
->
endWidget
();
?>
...
...
@@ -1193,9 +1199,11 @@ Yii::app()->clientScript->registerScript('siteIndex', "
'tabs'=>
\$
this->getTabularFormTabs(
\$
form,
\$
model),
)); ?>
<div class=
\"
form-actions
\"
>
<div class=
\"
form-group
\"
>
<div class=
\"
col-sm-offset-2 col-sm-10
\"
>
<?php
\$
this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'submit', 'type'=>'primary', 'label'=>'Submit')); ?>
<?php
\$
this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'reset', 'label'=>'Reset')); ?>
</div>
</div>
<?php
\$
this->endWidget(); ?>"
);
?>
...
...
@@ -1220,7 +1228,7 @@ Yii::app()->clientScript->registerScript('siteIndex', "
<legend><?php echo CHtml::encode(
\$
language); ?> translation</legend>
<?php echo
\$
form->textFieldRow(
\$
model,
\"
[
{
\$locale
}
]textField
\"
); ?>
<?php echo
\$
form->textAreaRow(
\$
model,
\"
[
{
\$locale
}
]textarea
\"
, array('
class'=>'col-md-8', '
rows'=>8)); ?>
<?php echo
\$
form->textAreaRow(
\$
model,
\"
[
{
\$locale
}
]textarea
\"
, array('rows'=>8)); ?>
<?php echo
\$
form->checkBoxListRow(
\$
model,
\"
[
{
\$locale
}
]checkboxes
\"
, array(
'Option one is this and that—be sure to include why it\'s great',
'Option two can also be checked and included in form results',
...
...
widgets/TbActiveForm.php
View file @
377fe8c2
...
...
@@ -45,10 +45,17 @@ class TbActiveForm extends CActiveForm
*/
public
function
init
()
{
$formType
=
''
;
if
(
$this
->
type
===
self
::
TYPE_VERTICAL
)
$formType
=
'form'
;
elseif
(
$this
->
type
===
self
::
TYPE_SEARCH
)
$formType
=
'form-inline'
;
else
$formType
=
'form-'
.
$this
->
type
;
if
(
!
isset
(
$this
->
htmlOptions
[
'class'
]))
$this
->
htmlOptions
[
'class'
]
=
'form-'
.
$this
->
t
ype
;
$this
->
htmlOptions
[
'class'
]
=
$formT
ype
;
else
$this
->
htmlOptions
[
'class'
]
.=
'
form-'
.
$this
->
t
ype
;
$this
->
htmlOptions
[
'class'
]
.=
'
'
.
$formT
ype
;
if
(
!
isset
(
$this
->
inlineErrors
))
$this
->
inlineErrors
=
$this
->
type
===
self
::
TYPE_HORIZONTAL
;
...
...
@@ -486,6 +493,13 @@ class TbActiveForm extends CActiveForm
*/
public
function
inputRow
(
$type
,
$model
,
$attribute
,
$data
=
null
,
$htmlOptions
=
array
())
{
if
(
in_array
(
$type
,
array
(
TbInput
::
TYPE_DROPDOWN
,
TbInput
::
TYPE_PASSWORD
,
TbInput
::
TYPE_TEXTAREA
,
TbInput
::
TYPE_TEXT
,
TbInput
::
TYPE_UNEDITABLE
)))
{
if
(
isset
(
$htmlOptions
[
'class'
]))
$htmlOptions
[
'class'
]
.=
" form-control"
;
else
$htmlOptions
[
'class'
]
=
"form-control"
;
}
ob_start
();
$this
->
getOwner
()
->
widget
(
$this
->
getInputClassName
(),
array
(
'form'
=>
$this
,
...
...
widgets/input/TbInput.php
View file @
377fe8c2
...
...
@@ -183,6 +183,7 @@ abstract class TbInput extends CInputWidget
*/
public
function
run
()
{
echo
'<div class="form-group">'
;
switch
(
$this
->
type
)
{
case
self
::
TYPE_CHECKBOX
:
...
...
@@ -241,6 +242,7 @@ abstract class TbInput extends CInputWidget
default
:
throw
new
CException
(
__CLASS__
.
': Failed to run widget! Type is invalid.'
);
}
echo
'</div>'
;
}
/**
...
...
@@ -268,9 +270,9 @@ abstract class TbInput extends CInputWidget
$htmlOptions
=
$this
->
prependOptions
;
if
(
isset
(
$htmlOptions
[
'class'
]))
$htmlOptions
[
'class'
]
.=
'
add-
on'
;
$htmlOptions
[
'class'
]
.=
'
input-group-add
on'
;
else
$htmlOptions
[
'class'
]
=
'
add-
on'
;
$htmlOptions
[
'class'
]
=
'
input-group-add
on'
;
ob_start
();
echo
'<div class="'
.
$this
->
getAddonCssClass
()
.
'">'
;
...
...
@@ -294,9 +296,9 @@ abstract class TbInput extends CInputWidget
$htmlOptions
=
$this
->
appendOptions
;
if
(
isset
(
$htmlOptions
[
'class'
]))
$htmlOptions
[
'class'
]
.=
'
add-
on'
;
$htmlOptions
[
'class'
]
.=
'
input-group-add
on'
;
else
$htmlOptions
[
'class'
]
=
'
add-
on'
;
$htmlOptions
[
'class'
]
=
'
input-group-add
on'
;
ob_start
();
if
(
isset
(
$this
->
appendText
))
...
...
@@ -368,10 +370,7 @@ abstract class TbInput extends CInputWidget
protected
function
getAddonCssClass
()
{
$classes
=
array
();
if
(
isset
(
$this
->
prependText
))
$classes
[]
=
'input-prepend'
;
if
(
isset
(
$this
->
appendText
))
$classes
[]
=
'input-append'
;
$classes
[]
=
'input-group'
;
return
implode
(
' '
,
$classes
);
}
...
...
widgets/input/TbInputHorizontal.php
View file @
377fe8c2
...
...
@@ -32,9 +32,9 @@ class TbInputHorizontal extends TbInput
protected
function
getLabel
()
{
if
(
isset
(
$this
->
labelOptions
[
'class'
]))
$this
->
labelOptions
[
'class'
]
.=
' control-label'
;
$this
->
labelOptions
[
'class'
]
.=
' co
l-sm-2 co
ntrol-label'
;
else
$this
->
labelOptions
[
'class'
]
=
'control-label'
;
$this
->
labelOptions
[
'class'
]
=
'co
l-sm-2 co
ntrol-label'
;
return
parent
::
getLabel
();
}
...
...
@@ -46,7 +46,7 @@ class TbInputHorizontal extends TbInput
protected
function
checkBox
()
{
$attribute
=
$this
->
attribute
;
echo
'<div class="co
ntrols
">'
;
echo
'<div class="co
l-sm-offset-2 col-sm-10
">'
;
echo
'<label class="checkbox" for="'
.
$this
->
getAttributeId
(
$attribute
)
.
'">'
;
echo
$this
->
form
->
checkBox
(
$this
->
model
,
$attribute
,
$this
->
htmlOptions
)
.
PHP_EOL
;
echo
$this
->
model
->
getAttributeLabel
(
$attribute
);
...
...
@@ -61,7 +61,7 @@ class TbInputHorizontal extends TbInput
protected
function
checkBoxList
()
{
echo
$this
->
getLabel
();
echo
'<div class="co
ntrols
">'
;
echo
'<div class="co
l-sm-10
">'
;
echo
$this
->
form
->
checkBoxList
(
$this
->
model
,
$this
->
attribute
,
$this
->
data
,
$this
->
htmlOptions
);
echo
$this
->
getError
()
.
$this
->
getHint
();
echo
'</div>'
;
...
...
@@ -84,7 +84,7 @@ class TbInputHorizontal extends TbInput
protected
function
dropDownList
()
{
echo
$this
->
getLabel
();
echo
'<div class="co
ntrols
">'
;
echo
'<div class="co
l-sm-10
">'
;
echo
$this
->
form
->
dropDownList
(
$this
->
model
,
$this
->
attribute
,
$this
->
data
,
$this
->
htmlOptions
);
echo
$this
->
getError
()
.
$this
->
getHint
();
echo
'</div>'
;
...
...
@@ -97,7 +97,7 @@ class TbInputHorizontal extends TbInput
protected
function
fileField
()
{
echo
$this
->
getLabel
();
echo
'<div class="co
ntrols
">'
;
echo
'<div class="co
l-sm-10
">'
;
echo
$this
->
form
->
fileField
(
$this
->
model
,
$this
->
attribute
,
$this
->
htmlOptions
);
echo
$this
->
getError
()
.
$this
->
getHint
();
echo
'</div>'
;
...
...
@@ -110,7 +110,7 @@ class TbInputHorizontal extends TbInput
protected
function
passwordField
()
{
echo
$this
->
getLabel
();
echo
'<div class="co
ntrols
">'
;
echo
'<div class="co
l-sm-10
">'
;
echo
$this
->
getPrepend
();
echo
$this
->
form
->
passwordField
(
$this
->
model
,
$this
->
attribute
,
$this
->
htmlOptions
);
echo
$this
->
getAppend
();
...
...
@@ -125,7 +125,7 @@ class TbInputHorizontal extends TbInput
protected
function
radioButton
()
{
$attribute
=
$this
->
attribute
;
echo
'<div class="co
ntrols
">'
;
echo
'<div class="co
l-sm-offset-2 col-sm-10
">'
;
echo
'<label class="radio" for="'
.
$this
->
getAttributeId
(
$attribute
)
.
'">'
;
echo
$this
->
form
->
radioButton
(
$this
->
model
,
$attribute
,
$this
->
htmlOptions
)
.
PHP_EOL
;
echo
$this
->
model
->
getAttributeLabel
(
$attribute
);
...
...
@@ -140,7 +140,7 @@ class TbInputHorizontal extends TbInput
protected
function
radioButtonList
()
{
echo
$this
->
getLabel
();
echo
'<div class="co
ntrols
">'
;
echo
'<div class="co
l-sm-10
">'
;
echo
$this
->
form
->
radioButtonList
(
$this
->
model
,
$this
->
attribute
,
$this
->
data
,
$this
->
htmlOptions
);
echo
$this
->
getError
()
.
$this
->
getHint
();
echo
'</div>'
;
...
...
@@ -163,7 +163,7 @@ class TbInputHorizontal extends TbInput
protected
function
textArea
()
{
echo
$this
->
getLabel
();
echo
'<div class="co
ntrols
">'
;
echo
'<div class="co
l-sm-10
">'
;
echo
$this
->
form
->
textArea
(
$this
->
model
,
$this
->
attribute
,
$this
->
htmlOptions
);
echo
$this
->
getError
()
.
$this
->
getHint
();
echo
'</div>'
;
...
...
@@ -176,7 +176,7 @@ class TbInputHorizontal extends TbInput
protected
function
textField
()
{
echo
$this
->
getLabel
();
echo
'<div class="co
ntrols
">'
;
echo
'<div class="co
l-sm-10
">'
;
echo
$this
->
getPrepend
();
echo
$this
->
form
->
textField
(
$this
->
model
,
$this
->
attribute
,
$this
->
htmlOptions
);
echo
$this
->
getAppend
();
...
...
@@ -191,7 +191,7 @@ class TbInputHorizontal extends TbInput
protected
function
captcha
()
{
echo
$this
->
getLabel
();
echo
'<div class="co
ntrols
"><div class="captcha">'
;
echo
'<div class="co
l-sm-10
"><div class="captcha">'
;
echo
'<div class="widget">'
.
$this
->
widget
(
'CCaptcha'
,
$this
->
captchaOptions
,
true
)
.
'</div>'
;
echo
$this
->
form
->
textField
(
$this
->
model
,
$this
->
attribute
,
$this
->
htmlOptions
);
echo
$this
->
getError
()
.
$this
->
getHint
();
...
...
@@ -205,7 +205,7 @@ class TbInputHorizontal extends TbInput
protected
function
uneditableField
()
{
echo
$this
->
getLabel
();
echo
'<div class="co
ntrols
">'
;
echo
'<div class="co
l-sm-10
">'
;
echo
CHtml
::
tag
(
'span'
,
$this
->
htmlOptions
,
$this
->
model
->
{
$this
->
attribute
});
echo
$this
->
getError
()
.
$this
->
getHint
();
echo
'</div>'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment