thymeleaf form assign to object th:block code example
Example 1: how to create object in php wihtout class
//You can use stdClass which is sort of empty template
$object = new stdClass();
//Assign property
$object->property = 'Here we go';
//Now if we dump it
var_dump($object);
/*
outputs:
object(stdClass)#2 (1) {
["property"]=>
string(10) "Here we go"
}
*/
//Even shorter
$object = (object) ['property' => 'Here we go'];
Example 2: form serialize object javascript
function objectifyForm(formArray) {//serialize data function
var returnArray = {};
for (var i = 0; i < formArray.length; i++){
returnArray[formArray[i]['name']] = formArray[i]['value'];
}
return returnArray;
}