99
1010trait FieldTrait {
1111
12- public abstract function addToProperty ($ name , $ value , $ separator =" " );
13- public abstract function addLabel ($ caption , $ style ="label-default " , $ leftSeparator =" " );
14- public abstract function addContent ($ content ,$ before =false );
12+ abstract public function addToProperty ($ name , $ value , $ separator =" " );
13+ abstract public function addLabel ($ caption , $ style ="label-default " , $ leftSeparator =" " );
14+ abstract public function addContent ($ content ,$ before =false );
15+ abstract public function getField ();
1516 public function setFocus () {
16- $ this ->addToProperty ("class " , State::FOCUS );
17+ $ this ->getField ()-> addToProperty ("class " , State::FOCUS );
1718 }
1819
1920 public function addLoading () {
@@ -24,8 +25,9 @@ public function addLoading() {
2425 }
2526
2627 public function labeled ($ label , $ direction =Direction::LEFT , $ icon =NULL ) {
27- $ labelO =$ this ->addLabel ($ label ,$ direction ===Direction::LEFT ,$ icon );
28- $ this ->addToProperty ("class " , $ direction . " labeled " );
28+ $ field =$ this ->getField ();
29+ $ labelO =$ field ->addLabel ($ label ,$ direction ===Direction::LEFT ,$ icon );
30+ $ field ->addToProperty ("class " , $ direction . " labeled " );
2931 return $ labelO ;
3032 }
3133
@@ -34,14 +36,15 @@ public function labeledToCorner($icon, $direction=Direction::LEFT) {
3436 }
3537
3638 public function addAction ($ action , $ direction =Direction::RIGHT , $ icon =NULL , $ labeled =false ) {
39+ $ field =$ this ->getField ();
3740 $ actionO =$ action ;
3841 if (\is_object ($ action ) === false ) {
3942 $ actionO =new HtmlButton ("action- " . $ this ->identifier , $ action );
4043 if (isset ($ icon ))
4144 $ actionO ->addIcon ($ icon , true , $ labeled );
4245 }
43- $ this ->addToProperty ("class " , $ direction . " action " );
44- $ this ->addContent ($ actionO , \strstr ($ direction , Direction::LEFT ) !== false );
46+ $ field ->addToProperty ("class " , $ direction . " action " );
47+ $ field ->addContent ($ actionO , \strstr ($ direction , Direction::LEFT ) !== false );
4548 return $ actionO ;
4649 }
4750
@@ -52,11 +55,15 @@ public function addDropdown($label="", $items=array(),$direction=Direction::RIGH
5255 }
5356
5457 public function setTransparent () {
55- return $ this ->addToProperty ("class " , "transparent " );
58+ return $ this ->getField ()-> addToProperty ("class " , "transparent " );
5659 }
5760
5861 public function setReadonly (){
5962 $ this ->getDataField ()->setProperty ("readonly " , "" );
6063 }
6164
65+ public function setName ($ name ){
66+ $ this ->getDataField ()->setProperty ("name " ,$ name );
67+ }
68+
6269}
0 commit comments