Source for file TSeekButton.php
Documentation is available at TSeekButton.php
namespace
Adianti \
Widget \
Form ;
use
Adianti \
Widget \
Form \
TForm ;
use
Adianti \
Widget \
Form \
TField ;
use
Adianti \
Widget \
Form \
TEntry ;
use
Adianti \
Widget \
Util \
TImage ;
* Record Lookup Widget: Creates a lookup field used to search values from associated entities
* @author Pablo Dall'Oglio
* @copyright Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
* @license http://www.adianti.com.br/framework-license
* @param $name name of the field
$this -> useOutEvent =
TRUE ;
$this -> setProperty ( 'class' , 'tfield tseekentry' , TRUE ) ; // classe CSS
$this -> input_size =
'100%' ;
$this -> button =
self :: createButton ( $this -> name , $icon ) ;
* Create seek button object
$image =
new TImage ( $icon ?
$icon :
'fa:search' ) ;
$button -> { 'class' } =
'btn btn-default tseekbutton' ;
$button -> { 'type' } =
'button' ;
$button -> { 'onmouseover' } =
"style.cursor = 'pointer'" ;
$button -> { 'name' } =
'_' .
$name .
'_seek' ;
$button -> { 'for' } =
$name ;
$button -> { 'onmouseout' } =
"style.cursor = 'default'" ;
* Returns a property value
* @param $name Property Name
public function __get ( $name )
return parent :: __get ( $name ) ;
* Define the Field's width
* @param $width Field's width in pixels
public function setSize ( $width , $height =
NULL )
if ( $this -> hasAuxiliar ( ) &&
empty ( $height )) // height is passed by BootstrapFormBuilder::wrapField() only
$this -> input_size =
$width ;
* Define it the out event will be fired
$this -> useOutEvent =
$bool ;
* Define the action for the SeekButton
* @param $action Action taken when the user
* clicks over the Seek Button (A TAction object)
* Define an auxiliar field
* @param $object any TField object
$this -> input_size =
$this -> size ;
if ( $object instanceof
TField )
$this -> action -> setParameter ( 'receive_field' , $object -> getName ( )) ;
* Returns if has auxiliar field
$this -> extra_size =
$extra_size ;
return $this -> extra_size ;
* @param $form_name Form name
* @param $field Field name
TScript :: create ( " tseekbutton_enable_field('{$form_name } ', '{$field } '); " ) ;
* @param $form_name Form name
* @param $field Field name
TScript :: create ( " tseekbutton_disable_field('{$form_name } ', '{$field } '); " ) ;
// check if it's not editable
if ( parent :: getEditable ( ))
// get the action class name
$rc =
new ReflectionClass ( $callback [ 0 ] ) ;
$ajaxAction =
new TAction ( array ( $class , 'onSelect' )) ;
if ( in_array ( $class , [ 'TStandardSeek' ] ))
$ajaxAction -> setParameter ( 'parent' , $this -> action -> getParameter ( 'parent' )) ;
$ajaxAction -> setParameter ( 'database' , $this -> action -> getParameter ( 'database' )) ;
$ajaxAction -> setParameter ( 'model' , $this -> action -> getParameter ( 'model' )) ;
$ajaxAction -> setParameter ( 'display_field' , $this -> action -> getParameter ( 'display_field' )) ;
$ajaxAction -> setParameter ( 'receive_key' , $this -> action -> getParameter ( 'receive_key' )) ;
$ajaxAction -> setParameter ( 'receive_field' , $this -> action -> getParameter ( 'receive_field' )) ;
$ajaxAction -> setParameter ( 'criteria' , $this -> action -> getParameter ( 'criteria' )) ;
$ajaxAction -> setParameter ( 'mask' , $this -> action -> getParameter ( 'mask' )) ;
$ajaxAction -> setParameter ( 'operator' , $this -> action -> getParameter ( 'operator' ) ?
$this -> action -> getParameter ( 'operator' ) :
'like' ) ;
if ( $actionParameters =
$this -> action -> getParameters ( ))
foreach ( $actionParameters as $key =>
$value )
$ajaxAction -> setParameter ( $key , $value ) ;
$ajaxAction -> setParameter ( 'form_name' , $this -> formName ) ;
$string_action =
$ajaxAction -> serialize ( FALSE ) ;
$this -> setProperty ( 'seekaction' , " __adianti_post_lookup('{$this -> formName } ', '{
$string_action } ', '{
$this -> id } ', 'callback')
" ) ;
$this -> action -> setParameter ( '_field_id' , $this -> id ) ;
$this -> action -> setParameter ( '_field_name' , $this -> name ) ;
$this -> action -> setParameter ( '_form_name' , $this -> formName ) ;
$this -> action -> setParameter ( 'field_name' , $this -> name ) ;
$this -> action -> setParameter ( 'form_name' , $this -> formName ) ;
$serialized_action =
$this -> action -> serialize ( FALSE ) ;
$this -> button -> { 'onclick' } =
" __adianti_post_page_lookup('{$this -> formName } ', '{
$serialized_action } ', '{
$this -> id } ', 'callback')
" ;
$wrapper -> { 'class' } =
'tseek-group' ;
$wrapper -> { 'style' } .=
" ;width:{$this -> size } ;
" ;
$wrapper -> { 'style' } .=
" ;width:{$this -> size } px;
" ;
$this -> size =
( $this -> hasAuxiliar ( ) ?
$this -> input_size :
" calc(100% - {$this -> extra_size } px)
" ) ;