I am new to joomla.
I have created a component using component creator. I've a form in admin side storing the details of a location, when the detail is saved I need to get the last insert id of this table to insert in another table with some extra details.
I would like to know how to get the inserted id and where the submit action goes.
Component folder in the Administrator includes all the components we use. view.html.php file includes the action to be done.
JToolBarHelper::save('yourcontrollername.save', 'JTOOLBAR_SAVE');
The save function calls the default save event. To include your custom action, define a save function in the controller.
Related
I have a Insert form for Account Entity.
Once user create Record, I want to move to another page and show same record as Edit Form.
Does anyone have idea way to achieve this?
You should be able to redirect the user to desired page using OnSuccess of form submission.
On success: Select one of the following options:
Show success message: Requires a message to be displayed to the
user on successful submission of the form. You can also select Hide
form on success to hide the form upon successful submission.
Redirect to webpage: Redirects the user to the selected webpage
in the portal. You must select a webpage from the Redirect to webpage
list.
Redirect to URL: Redirects the user to the specified URL. You
must enter a URL in the Redirect to URL field.
Read more
Out of Box configuration helps!!!
There is a field on "Entity Form" records named "Append Record ID to Query String". This is to configure passing the id of the record to the page after form submission. This screenshot shows it in the Redirect Section in the classic interface
You can do this several ways. What I do, is use Navigate() to go to the new screen, and I pass in a context variable to the new edit screen.
Assuming you're using OnSelect() on a button to call SubmitForm(), you can do the Navigate() call via the OnSuccess() property of the form.
And within Navigate(), you just pass whatever data you need to in order for the next screen to properly bind it to the Edit Form. This is the UpdateContextRecord optional param. You'd have the Edit form take its values from a Context Variable.
Passing variables between screens has been discussed here, as well.
Question is: How to show data in data-view in such a way that if entity is updated some how dataview is updated too.
This is my Entity named latestReading.
Here is my page LatestReading that show latest readings. It contains three data views.
This page is not called directly, as it expect a object latestReading. Hence a micro-flow named showLatestReadingPage is executed that fetches or create latestReading object and pass it to the LatestReading page and display LatestReading page.
Here is that micro-flow.
getOrCreateLatestReading is a micro-flow that returns us the a latestReading object if it is available or create a new latestReading object if it is not already created and then returns it.
Here is that micro-flow.
These are the properties of first of the three data-views in LatestReading page as shown diagram of LatestReading Page above. Name of this DataView is TemperatureDataView
These are the properties of text widget that is inside TemperatureDataView data-view. Its name is temperatureText. It shows value of temperature in the TemperatureDataView.
And this is the caption of temperatureText text widget:
Problem is when another micro-flow updates the value of latestReading the text widget is not updated. I need to reload it by clicking on navigation link of LatestReading page again.
I need my text widget in data view to keep updating value of latestReading when it is updated my some other micro-flow
The issue is that ‘refresh in client’ only works if the microflow is executed in the same context as the page (client) that the user is seeing. For example if there is a button on the page that triggers a microflow that refreshes the client then it will update the widget. However, if the microflow is triggered by the system (e.g. a scheduled event) then these changes are in a different context. Also if another user triggers a refresh it will only refresh that user’s client. Also if one user is logged in through multiple browsers (i.e. has multiple sessions, it also means that for each session there is a different user context.
The simplest solution in this case would likely be to use an appstore widget that periodically triggers a refresh on the object displayed in the dataview, such as this one: https://appstore.home.mendix.com/link/app/27/ . Simply create nanoflow or microflow with a change action that changes no attributes but refreshes the object.
I have an edit form for a Post record, and I'm listing the Reviews associated with that Post in a ReferenceManyField/DataGrid (ie <ReferenceManyField target="post_id" reference="reviews">). Each Review has the foreign key post_id in the DB. This is all working fine, I have an edit and delete button for each Review row.
I need to add a 'Create Review' button for the Post form, such that the post_id field in the Create Review form is pre-populated with the current id of the Post. I'm not very expert in React/Redux.
As #Gildas has suggested above, you need a custom component for that.
1) A custom create button that routes to a create page for the review. For this you should look at how the React Router Link component documentation as well as how Admin On Rest would allocate a route for instance /:reviewId/create
2) Create a custom input component that will prefill the ID when loaded. This should be part of the location key in the props passed to your page. Ask additional questions as comments and I will try and answer them.
React and Redux are really simple things when you get the hang of them
This is not possible directly for now: you'll have to create a custom component for that: documentation.
Someone tried to address this issue and even supplied a pull-request. Hopefully we'll be able to merge it soon: https://github.com/marmelab/admin-on-rest/pull/744
Edit: this might help https://marmelab.com/blog/2018/07/09/react-admin-tutorials-form-for-related-records.html
I've already created a custom module that overrides the sales/order/view/tab/info.phtml layout file and creates a new field in the sales_flat_order table. Now I need figure out how to add a text input field to the order page:
The save button doesn't necessarily need to be right near the custom field and the field doesn't need to necessarily appear right where I put it in the graphic. Bottom line is, the administrator needs to be able to edit my new custom field in the admin.
What is the best way to do that?
Look at Comments History block
implementation - class Mage_Adminhtml_Block_Sales_Order_View_History, its template \app\design\adminhtml\default\default\template\sales\order\view\history.phtml and Mage_Adminhtml_Sales_OrderController::addCommentAction(). You should create similar block class with similar template and create controller with action which will save form data to your db field.
I've added a custom button into my component's backend toolbar with this code:
JToolBarHelper::custom('libri.details','details.png','details.png','TOOLBAR_DETAILS',true);
This button needs that the admin checks one of the entries listed in the table.
You can see a screenshot here if you haven't understood what I'm talking about
The button is the one called "Dettagli" (no image at the moment).
I'm having some problems:
How do I append the checked entry's id to the address generated from the button?
I've put a details() method into the controller, it calls an instance of the model and a method inside it. The model's method returns to the controller the result of a query. How do I say to the controller to pass that result to a view called libro?
All information in the page will be sent through POST to the Joomla controller (in this case, libri). In your controller, you can use JRequest::getVar('varNameHere'); to retrieve it.
$this->setRedirect($urlOfView, $someStatusMessage)