$this->request
Object from your controller.
ROM is not limited in your Controller, you can even use them outside of your controller, actually $this->request
Object in Controller is a reference to $request
global object. So You can use $request
global Object anywhere in your Application. So whatever you can do with $request
you can do that same thing with $this->request
and vice versa.
$request
or $this->request
object is an Instance of zRom Class. $_GET
as previous. However $this->request->get
also let You not only access GET request parameters also do more with them.$this->request->get->items
is an associative array just like $_GET. $this->request->get->valueOf('fieldName');
will also return value of that form field if the form field exists else return false. e.g. If your error level is E_NOTICE
PHP will fire Notice if you try to use $this->request->get->items['someNonExistingField']
It will say index doesn't exist or similar Notice message. But if you use $this->request->get->valueOf('someNonExistingField')
It will return false so PHP will not fire any message.
$this->request->get
might seem to be big to write so in your controller You can use $this->getPeer
Thats a reference to $this->request->get
;
$this->request->get
is an instance of zRom_form Class.$this->request->get->isSubmitted()
Zigmoyd lets you Validate both get and post requests in the same way. and obviously through [[validation]] map. You put a [[validation]] map with .vld.map.php
in etc/conf.d
Directory in your Project's directory. assume your [[validation]] Map name is abcd.vld.map.php
you need to invoke $this->request->get->initValidator('abcd');
To use that [[Validation]] Map to validate get request.
after you have invoked initValidator()
[[validation]] has also been done and you can see the result. If you now invoke $this->request->get->isValid
it will return you a boolean value wheather or not the form is completely valid.
you can also check on the basis of particular form field. after invoking initValidator()
you will get Objects representing their corresponding form fields e.g. $this->request->get->formFieldName
. so If you have a form field called name
it will be represented by $this->request->get->name
which will have a method called isValid()
by which you can check wheather or not that name
form field is valid. you can also do several other things like.
$this->request->get->name->value
$this->request->get->name->isValid
$this->request->get->name->isValid()
$this->request->get->name->err_msg
$this->request->get->name->validationStatus
$_POST
as previous. However $this->request->post
also let You not only access POST request parameters also do more with them.$this->request->post->items
is an associative array just like $_POST. $this->request->post->valueOf('fieldName');
will also return value of that form field if the form field exists else return false. e.g. If your error level is E_NOTICE
PHP will fire Notice if you try to use $this->request->post->items['someNonExistingField']
It will say index doesn't exist or similar Notice message. But if you use $this->request->post->valueOf('someNonExistingField')
It will return false so PHP will not fire any message.
$this->request->post
might seem to be big to write so in your controller You can use $this->postPeer
Thats a reference to $this->request->post
;
$this->request->post
is an instance of zRom_form Class.$this->request->post->isSubmitted()
Zigmoyd lets you Validate both post and post requests in the same way. and obviously through [[validation]] map. You put a [[validation]] map with .vld.map.php
in etc/conf.d
Directory in your Project's directory. assume your [[validation]] Map name is abcd.vld.map.php
you need to invoke $this->request->post->initValidator('abcd');
To use that [[Validation]] Map to validate post request.
after you have invoked initValidator()
[[validation]] has also been done and you can see the result. If you now invoke $this->request->post->isValid
it will return you a boolean value wheather or not the form is completely valid.
you can also check on the basis of particular form field. after invoking initValidator()
you will post Objects representing their corresponding form fields e.g. $this->request->post->formFieldName
. so If you have a form field called name
it will be represented by $this->request->post->name
which will have a method called isValid()
by which you can check wheather or not that name
form field is valid. you can also do several other things like.
$this->request->post->name->value
$this->request->post->name->isValid
$this->request->post->name->isValid()
$this->request->post->name->err_msg
$this->request->post->name->validationStatus
$this->request->session
. which is actually an instance of zSession Class. When Instantiated you can additionally do some magic operations like $this->request->session->setEncryptedKey('key'), $this->request->session->getEncryptedKey(), $this->request->session->setKey('value'), $this->request->session->getKey('value'), $this->request->session->getKey()
However you can still use $_SESSION
$this->request->cookie
. which is actually an instance of zCookie Class. When Instantiated you can additionally do some magic operations like $this->request->cookie->setEncryptedKey('key'), $this->request->cookie->getEncryptedKey(), $this->request->cookie->setKey('value'), $this->request->cookie->getKey('value'), $this->request->cookie->getKey()
However you can still use $_COOKIE
transfer/up
Directory in your Project's directory.
Upload works more or less same as GET/POST requests and is very simple.First you should check wheather or the form has been submitted using $this->request->file->isSubmitted()
, however you can also do this through $this->isUploadRequest()
.
Now Invoke doUpload() Method $this->request->file->doUpload()
that does the Uploading job.It returns true/false
depending upon success or failure.
You can simply code something like.
if($this->request->file->isSubmitted()){ if($this->request->file->doUpload()){ //Uploaded Successfully }else{ //Problem while Uploading } }else{ //Form not yet Submitted } \sa See \ref uploadPage "Upload Page" for more information on it.
$this->request->file->initValidator()
method in the same way. $this->request->client
to get Client Request attributes and $this->request->server
to get server information. You can execute (you can understand their usage by their names)
CLIENT_OS Holds the Operating System name of Client as a string. and you can run a switch case using CLIENT_OS in the switch and other IS_.... in cases.
Same applies in Browser Checks too.