I use input form in admin dashboard for changing values in custom config file that is loaded in codeigniter over autoloading. I have issue that after submiting(saving), form values are saved in config file but they are not updated in $this->config->item.
After sending form data to controller and successful saving in config file page is reloaded. Right(updated) values appear in input fields only after one more reload. If config file is loaded only in current controller (not over autoloading) it works ok, but it is needed in many controllers and models. How do I resolve this issue?
As far as i know the data loaded in autoloader is loaded before controller execution. So if you change the data in a called controller it will always differ until reload.
I would recommend handling the data either in a database table or manage it manually in a file (outsource file operation in a library).
Related
I have followed tutorial: http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html
but I have problem handling situation when I upload file, but other field does not meet validation criteria and user is directed to fix form errors. Then when user fix problem and hit submit button, he no longer has valid image in form and missing file error is displayed.
I have prepared small example project to illustrate this behavior:
https://github.com/Jaslanin/sf_upload_form_error
Steps to reproduce this behavior:
open web/ dir of project inside browser
in name field put string "123"
set image file for file field
hit submit button
change name field to "123456"
hit submit button
observe that form has missing file error
For now I handled this problem using steps within "How to Handle File Uploads with Doctrine" tutorial, but without using lifecyclecallbacks. I run ->upload manually and in case of error store file path inside session.
It works, but I am looking for cleaner solution for that problem.
When you render the form on your page all input fields are populated with values from an entity or an array. The key point here is that you have no data to pre-populate file input field. So it renders as empty input. And when user hits submit on step 6, there is no file selected/uploaded. Your solution with a session-stored uploaded file path is proper solution in this case.
I also suggest you to show to user, that some file has been already submitted when there is one in the session.
I currently have a site I built using jquery/php/PDO/mysql.
I use classes for most functions, including database, logins, content, etc...
I am wanting to change my forms over to jquery's ajax calls. But there's where my problems start. With the ajax call, I can't call a php function in the ajax post url. Heres the heirarchy Im using;
->content.php (form resides in a function named content.)
->process.php (post checks and then a call to add content from class)
->class.content.php (insert vars into db)
Once form is submitted, it goes to process.php which contains checks and then a class call to add content.
While this hierarchy seems to be the most used for ajax, it causes path issues. It breaks my db connection, my config connection, etc...
All I really want is to add ajax forms. But I don't want to rewrite my whole site. Any suggestions?
It sounds like process.php was previously included in content.php but now you're trying to submit to it directly. However, process.php was dependant upon the configuration variables, database connection etc. which was included in content.php and accessible by being included within that page.
I think you need to make a new page which includes the same other files and has the same initialisation code as content.php, except it doesn't output the form and instead just includes process.php, then submit to the new page.
Hard to say for sure without code though.
Has anyone faced this feature request and were able to resolve it? We have a webapps that is capable of creating a form as a template. That template will basically be called and user will need to fill out the form before it got push into the db. So the form is created directly inside the application and the fields, labels and variables are all defined when the form is created by user using the apps. Since the form is always going to be changing, I can't hardcode the activity in android and have to create it manually and recompile every time a new form is created. Is there a way for us to read the label, variables setting that's stored in db either in XML format or called as JSON and build the form dynamically everytime the form is called via android? Am I making any sense? Please advise?
Yes. Everything you do in XML (view creation, positioning etc) can be done dynamically via code as well.
A simple way would to be to put a single ScrollView with a single LinearLayout inside it. Then in your activities onCreate(), you can read your JSON or XML file just like any other file (you can store this is assets folder or maybe query it from your backend). Then depending on your variables you can initialize and add TextViews and EditText's to the LinearLayout. The ScrollView will expand infinitely to accommodate all your form elements.
Just make sure you don't do any long-running operation such as querying from your backend or reading from your file in the main UI thread. Another caveat is that if ScrollView does not recycle views and putting too many views in it (say more than 20) can make your application run out of memory and slow down/crash.
You can create a form in relative layout having all the fields/view you require in XML, then on Runtime in code According to your label name in db or whatever you are using, you can hide/show the fields/view which are needed dynamically. This way you can preserve the position and setting of each field as when 1 view is hidden other views are going to take its position.
I have a line of code I wish to run after a view script has rendered, but I want this code to be placed in the action.
This is action specific and only updates a flag in the database, so it seems like overkill to utilise a plugin just for this.
What other options do I have? Could I register an abstract plugin that I can extend and hook into dispatchLoopShutdown() or routeShutdown() from the specific action I am in?
Thanks
By default 'View' is the last thing that the pointer will pass through.
you can:
$this->_helper->removeHelper('viewRenderer');
to globally remove views and then do the rest of action.
Actually, in many of my codes, I load views in chunks and have not faced any issues whilst rendering them before. Example, if I do:
$this->view->shouldGoinHeader;
// some actions here
$this->view->someHere;
// some more action thing
It works! So you can update a flag on your database using try catch if you are checking if view has been rendered.
If something is getting executed, you might want to post your codes?
I have an Entity on Symfony that has also a file "attached" to it.
I want to save the file with the id of the created Entity.
The problem is, that I will know the Entity's ID only after doing "dosave()" on that
Entity form.
Is there any way to save the file after doing the "dosave()" but still write the code
as an override for the Entity's form code?
Assuming you are using symfony's bundled file widget, then you can't do this, because of the way the form save process works. In short, the file is saved by the validator, but by the nature of it being a validator, the data hasn't been saved yet!
I've worked around this before by using a temporary filename for the file if the object is new, and then after save has completed (but still within an overload in the form class), move it to the real location now that you know the id.