Get KoolPHP UI with 30% OFF!

Support of other Kool* controls in KoolForm

Riho Ellermaa
Hi!
It would be nice to be able to use for example KoolCombobox with all the extra features inside KoolForm. Now I'm stuck to the basic KoolDropDownList.
Posted Dec 27, 2015 Kool
Peter
Could you please let us know your difficulty. May be leave some code so that we know what you try to do, we will then create example for that.
Posted Dec 28, 2015 Kool
Riho Ellermaa
Actually after writing this, I went boldly ahead and just put the KoolCombobox next to KoolForm fields and handled the reading/writing separately, so main problem solved.
But it would help things if other input components (KoolCombobox, KoolInput,..) would be inherited from _KoolFormElement and so could be handled together with KoolForm built in form elements
Posted Dec 28, 2015 Kool
ADavid Wulkan
I thought I could addControl a datepicker control (startdate) to my form but, it sounds like this is not supported? This code works only if I comment out the code for the calendar/datepicker control. Has anyone been successful adding a calendar control to a KoolForm?
formfull.php
<?php include "inc/header_inc.php"; ?>
<?php include "inc/dbkool.php"; ?>
<?php //-----------------------------------------------------------------
      //     FORM CONTROL
      //-----------------------------------------------------------------
	require $KoolControlsFolder."/KoolAjax/koolajax.php";
	require $KoolControlsFolder."/KoolGrid/koolgrid.php";
	require $KoolControlsFolder."/KoolForm/koolform.php";
	require $KoolControlsFolder."/KoolCalendar/koolcalendar.php";	
	
	$koolajax->scriptFolder = $KoolControlsFolder."/KoolAjax";
	
	$myform_manager = new KoolForm("myform");
	$myform_manager->scriptFolder = $KoolControlsFolder."/KoolForm";	
	$myform_manager->DecorationEnabled = true;
	$myform_manager->styleFolder = "sunset";
 
	//TXTAGE - Use the numeric textbox
	$txtAge = $myform_manager->AddControl(new KoolNumericTextBox("txtAge"));
	//Use the masked textbox for phone
	$txtPhone = $myform_manager->AddControl(new KoolMaskedTextBox("txtPhone"));
	$txtPhone->Mask = "(###)-### ####";
	$txtPhone->SelectionOnFocus = "CaretToBeginning";
 
	//TXTNAME - Create the required field validator
	$txtName_RequiredFieldValidator = $myform_manager->AddControl(new KoolRequiredFieldValidator("txtName_RequiredFieldValidator"));
	$txtName_RequiredFieldValidator->TargetId = "txtName";
	$txtName_RequiredFieldValidator->ErrorMessage = "The textbox can not be empty!";
	
	//TXTAGE - Create the required field validator
	$txtAge_RequiredFieldValidator = $myform_manager->AddControl(new KoolRequiredFieldValidator("txtAge_RequiredFieldValidator"));
	$txtAge_RequiredFieldValidator->TargetId = "txtAge";
	$txtAge_RequiredFieldValidator->ErrorMessage = "Please, select an year number!";
	
	//TXTAGE - Create the range validator
	$txtAge_RangeValidator = $myform_manager->AddControl(new KoolRangeValidator("txtAge_RangeValidator"));
	$txtAge_RangeValidator->TargetId = "txtAge";
	$txtAge_RangeValidator->ErrorMessage = "Year number should be a non negative less than 50.";
	$txtAge_RangeValidator->MinValue=0;
	$txtAge_RangeValidator->MaxValue=49;
	
	//TXTPHONE - Create the required field validator
	$txtPhone_RequiredFieldValidator = $myform_manager->AddControl(new KoolRequiredFieldValidator("txtPhone_RequiredFieldValidator"));
	$txtPhone_RequiredFieldValidator->TargetId = "txtPhone";
	$txtPhone_RequiredFieldValidator->ErrorMessage = "Please enter phone number!";
	
	//TXTPHONE - Create the regular expression validator
	$txtPhone_RegularExpressionValidator = $myform_manager->AddControl(new KoolRegularExpressionValidator("txtPhone_RegularExpressionValidator"));
	$txtPhone_RegularExpressionValidator->TargetId = "txtPhone";
	$txtPhone_RegularExpressionValidator->Expression = "/\d{9}/";
	$txtPhone_RegularExpressionValidator->ErrorMessage = "Format is (###)-######";
 
	
	//TXTEMAIL - Create the required field validator
	$txtEmail_RequiredFieldValidator = $myform_manager->AddControl(new KoolRequiredFieldValidator("txtEmail_RequiredFieldValidator"));
	$txtEmail_RequiredFieldValidator->TargetId = "txtEmail";
	$txtEmail_RequiredFieldValidator->ErrorMessage = "Please, enter an e-mail!";		
 
	//TXTEMAIL - Create the regular expression validator
	$txtEmail_RegularExpressionValidator = $myform_manager->AddControl(new KoolRegularExpressionValidator("txtEmail_RegularExpressionValidator"));
	$txtEmail_RegularExpressionValidator->TargetId = "txtEmail";
	$txtEmail_RegularExpressionValidator->Expression = "/^[\w\.\-]+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*(\.[a-zA-Z]{2,3}){1,2}$/";
	$txtEmail_RegularExpressionValidator->ErrorMessage = "Please, enter valid e-mail address.";
 
	
	//STARTDATE
        $startdate = $myform_manager->AddControl(new KoolDatePicker("startdate")); //Create calendar object
	$startdate->scriptFolder = $KoolControlsFolder."/KoolCalendar"; //Set scriptFolder
	$startdate->styleFolder="default";
	$startdate->DateFormat = "m/d/Y";
	$startdate->Width="100px";
	$startdate->Init();
 
	
	$myform_manager->Validate = true; //Validate form before post
	$myform_manager->RenderWithExistingMarkup = true; //Use existing page layout
	$myform_manager->StatePersistent = false;//Don't keep state persistent after postback.
	$myform_manager->Init();
?>
 
<form id="myform" method="post">
<fieldset style="width:600px;padding-left:5px;padding-bottom:5px;" class="decoration">
  <legend>Please enter information</legend>
<table style="margin-top:5px;">
<tr><td>
  <table style="margin-top:5px;">
    <tr><td style="height:25px;width:75px;">Name:</td>
        <td><input id="txtName" name="txtName" type="text" />
         <span id="txtName_RequiredFieldValidator"></span>
       </td>
    </tr>
    <tr><td style="height:25px;">Age:</td>
        <td><input id="txtAge" name="txtAge" type="text" />
            <span id="txtAge_RequiredFieldValidator"></span>
            <span id="txtAge_RangeValidator"></span>
       </td></tr>
    <tr><td style="height:25px;">Phone:</td>
        <td><input id="txtPhone" name="txtPhone" type="text" />
            <span id="txtPhone_RequiredFieldValidator"></span>
            <span id="txtPhone_RegularExpressionValidator"></span>
       </td></tr>
    <tr><td style="height:25px;">Email:</td>
        <td><input id="txtEmail" name="txtEmail" type="text" />
            <span id="txtEmail_RequiredFieldValidator"></span>
            <span id="txtEmail_RegularExpressionValidator"></span>
       </td></tr>
  </table>
  </td></tr>
  <table style="margin-top:5px;">
  <tr><td width="100px" style="vertical-align:top">
            <div style="padding-top:10px;padding-bottom:10px;">
              Start date (mm/dd/yy):
              <br/>
              <?php echo $startdate->Render();?>
              <?php
                if($startdate->Value!=null) {
                   echo "<b>Start date:</b> ".$startdate->Value;
                }
               ?>
		
            </div>
     </td>
  </td></tr>
  </table>
</td></tr>
</table>
<div style="margin-bottom:5px;margin-top:5px;">
<input type="submit" value="Submit">
</div>
			
<?php
 if($myform_manager->IsPostBack) {
    echo "<div style='margin-bottom:5px;font-size:bold;'>Form is posted sucessfully!</div>";
 }
?>
</fieldset>
<?php echo $myform_manager->Render();?>
</form>
Posted Jan 31, 2016 Kool
ADavid Wulkan
Does anyone have code they can share how they got a calendar-datepicker control added into a koolform?
Posted Feb 2, 2016 Kool
Javier
I am trying to do this and I get this error message
Notice: Undefined property: KoolDatePicker::$_UniqueID in C:\wamp64\www\golem4\KoolPHPSuite\KoolControls\KoolForm\koolform.php on line 890
Posted Dec 20, 2018 Kool