I have a system which has certain page content stored in the database. Within this text we have the ability to add in custom scripts such as {WIDGET_FORM} which replaces the text with the content of a class named app_resource_widget_form. Up until now this has worked but the form needs to be created by Zend Form. Unfortunately the function which creates this requires a string(html) to be returned as so far i can only return the zend form object. Does any one know if what i am trying to do is possible. At some point the form must get created as html, is there a way to manually call this and then use that?
Thanks in advance
Zend_Form has a __toString() method, so:
$html = str_replace('{WIDGET_FORM}', $form->__toString(), $html);
Related
The functionality I have written works, this is for a test method.
In apex test code, I create a StandardController then a controller extension and invoke a method on that controller extension which returns a PageReference to a custom object's standard edit page. I want to change field values on that edit page and invoke the Save method/button, is this possible and how?
In advance, thanks.
No, you cannot change values in a standard edit screen from within a test method, nor do you need to. The correct way to test logic that is executed after saving on a standard edit screen is to construct an instance of a new record, populate the fields, and insert it into the database.
This is probably easy to do but I've spent hours searching Composite C1 knowledge base and google but nothing.
I simply want to create an html form, then when the user submits it, be able to process the form fields in C#. I don't mind if this uses web forms, MVC or some other mechanism.
I have got inline functions working but it's not clear how to pass in the form fields.
thx.
The Form Submit Handler is a simple addon that accepts all the values posted to the page and saves it to files on the server.
It can be a good starting point to see how to work with Forms withing C1. The code for it is available on GitHub.
I am a composite c1 noob myself, but one thing that I did and it seemed fairly straight forward was to understand how the contact form that comes with the Venus starter site works.
The Venus template contact form is driven by the function found in Functions > Razor > Composite > Form > Contact Form.
You can edit that function and you can see how it's implemented. Inside that function you have access to the form data and you can do pretty much whatever you want with it, since it's C# and Razor.
Additionally, you can create a custom Global Datatype and optionally an associated Page Datafolder to save your data, or have access to it outside the form function. These will have to be bound to the form function.
You can get the data submitted from the form using the automatically generated functions (should be located under Functions > All Functions > YourNamespace > YourDatatype). I've used the GetMyDataTypeXml function for what I was needing and it worked without issues.
You can read more about data functions here: http://docs.composite.net/Data/Data-Centric-Functions
Some examples of using the GetMyDatatypeXml function can be found here: http://docs.composite.net/Data/Data-Centric-Functions/Getting-Data-as-XML
HTH!
Context: I'm generating a PDF in a model callback (afterSave). I found a library I'm comfortable with called FPDF. I'm adding the FPDF class as a vendor.
So, without going into too much detail, essentially, once all checks have been completed for a particular contract application, the app needs to prepopulate a PDF file and attach it to an email.
I can figure everything out except how to generate the PDF in the model. I want to use a view to pass view vars to so that I can populate the template file and use the FPDF class to save a PDF file.
This file will in turn be attached the automated email and sent to the applicant.
So the flow is:
Once all checks have been complete (via crons and a CakePHP Shell), we trigger a function inside the model afterSave callback.
The function performs some logic and determines whether a declined or approved email should be sent.
If approved, then a PDF is generated using a view file and saved in /Views/pdf/
This file is attached to CakeEmail object and sent.
It's just the view rendering part here that I'm stuck with:
3. If approved, then a PDF is generated using a view file and saved in /Views/pdf/
How can I populate a view file with view variables and return the result into a variable?
For example, think of how the CakeEmail class does it with the CakeEmail->template('example') function......
Any ideas?
The answer is to construct your view class manually:
$view = new View(null, false);
$view->set(compact('variable1', 'variable2'));
$view->viewPath = 'ViewFolder';
$output = $view->render('view_file', 'layout');
I'm building my first CodeIgniter app - and have a registration form. I'm using the built-in form validation class to validate the data, and am at the point of adding that data to the database.
Should I be taking that data from the form validation class or from the input class ($this->input->post('username'))?
I'm guessing the correct way is from the input class, but just wanted to be sure. If that's the case, if there any prepping of the data I need to do before it gets inserted into the database such as 'trim'?
Thanks
Yes you would get the data from the input class. Operations such as trim() can be done using the form validation library by adding the trim to the set of rules for validation. When the validation is done, your data is ready to be inserted to the database.
I've always used $this->input->post('lalal'); and found it to work since the validation is already done when i use the values. But you could also use the set_value('lalal'); helper function, this is particularly useful if you found an error but don't want the user to entery every form field again but just the one that was faulty.
Your prepping of the data should be in the validation rules, you can add any php-functions that take one argument, ie trim, also you can call on the helper functions CI offers if they are loaded when the validation happens. And you have the built-in's that CI has with the validation class.
For more info check out: http://codeigniter.com/user_guide/libraries/form_validation.html#thecontroller
I have a problem with the custom eval functions when the record is called from an IRRE field, in particular with the JavaScript function.
For example I open to edit the base record of "table1", then I click an IRRE field to create a record to the "table2", the fields of the records of "table2" have eval user functions that works Ok in normal editing, but when in IRRE the functions only work after save the form, so the first time when the record is created those functions are not doing them jobs.
I don't understand where is the problem, maybe the Javascript code is not loaded. How can I add that file manually to the backend template? How can I face this situation?
I tried to debug with console and when the functions are called these files are present:
alt_doc.php:765
jsfunc.evalfield-e6a70fd19bf472ef08fa4754aae256b8.js:69
jsfunc.tbe_editor-def45aac90022eed51193264931eefb3.js:660
alt_doc.php:408
alt_doc.php:409
Thanks in advance.
It is a problem with the launch of the JS code. When you open the parent form the JS code of the fields that use eval in the IRRE form is not launched, when you saved the form with the IRRE created, Typo3 reloads the frame and now the JS is accesible.
I don't know a trasparent way to by-pass this, you must save the parent form after create the IRRE form in order to use the JS custom eval code of the IRRE form.