I addded a custom field in mdl_user in SQL, I want to show this custom field in the frontend, in profile edit page - moodle

I am using Moodle 3.8, I added a custom field called razon_social, I just want to show it in the profile edit page, in the optional section.
Custom field added in mdl_user
Section where I want to show my custom field
Does anyone know in which file in .php, do I have to call my custom field?
Thank you very much for your time
I want to do this, I have Moodle 3.8
enter image description here

Adding a custom field to the mdl_user table (or any other core table) is a really bad idea. There are all sorts of ways it can conflict with the core code (particularly for tables which Moodle uses with "persistent" classes, but still a problem in other situations).
Thankfully, Moodle already has a build in custom user field system (using the tables mdl_user_info_field and mdl_user_info_data) and fields defined this way automatically appear on the user profile page (unless you mark them as hidden).
It should be fairly easy to write a script that will transfer the data from the mdl_user field you created, into a custom user field. After that, you can drop the extra field you added.

Related

Will adding all attrbiutes to PreImage/PostImage to plugin step have impact on performance?

When registering plugin images and selecting all attributes to the image, the Plugin Registration Tool says that
"This plug-in will execute on all changes to the attributes associated to this message type!. This can create performance issues for your application and it is recommended that you filter your step registration to trigger on only the attributes you care about".
I set filtering attributes for the step.
So will setting filtering attributes save me from what that caution says?
For Example if you have Plugin on Update of Contact and filtering attribute is set to All, It will run on any field change on contact and this will definitely cause performance issue.
Now when you have filtering attribute set to only few fields for example fist name, last name and so on it will restrict to fire your plugin only on those field.
You can get all the attributes in pre image and post image but best case it to select only those attributes you need in your transaction.
Adding all fields in Pre and Post image will not add much burden/impact on your performance, but it will definitely add performance issue if your filtering attribute has all the fields selected.

How to implement custom field to show a modal to add a new CRUD?

I need to make "add new" button on select2_multiple field. Which show a modal to add new item.
I have no idea how to implement this type of custom field.
You should check out https://github.com/webfactor/laravel-backpack-instant-fields - they've already created a field type with this functionality, but I believe it's only for 1-n relations.
Creating a new field type isn't difficult at all, it's just adding one blade file in your resources/views/backpack/crud/fields folder. Documentation here. That file will include all the PHP and JS logic you want. However, creating this particular field type will be more complicated, it will involve a lot of Javascript, and most likely an AJAX request to a route and controller method you create.
In Backpack v4 we plan for this to be an official feature. We're still 1-2 months away from v4, though.

How to customized fieds in moodle forms?

I want to customize moodle course/edit_form.php file and add some more fields and remove some existing fields. Is this possible to do without changing core files?
I followed this article but didn't find anything helpful https://docs.moodle.org/dev/Form_API
You can create a plugin that has a form which saves extra information about the courses and then you can show those fields by overriding the course renderer in the theme.

Add Custom User Field (Dropdown) in Moodle

Hi I need to add Custom User Field (Dropdown) in Moodle. I know I can add it through https://docs.moodle.org/24/en/User_profile_fields and https://docs.moodle.org/dev/User_profile_fields
I went ahead with above method and added dropdown accordingly. However, when I see it in database, {user_info_field} it shows only one row with my select fields seperated by new line. Screenshot is listed.
I want these params to be appear in separate rows. Because, I've few development in pipeline which involves creation of custom invoicing plugin that allows to store pricing for each university.
That is how dropdown fields store their options in Moodle - all the values, separated by newlines.
If you want a list of possible values, retrieve mdl_user_info_field.param1 then use explode("\n", $fieldvalue).
I Used in built cohort system to categorized users in different University. Here I didn't have to create custom profile field.
For invoicing plugin, I will manipulate same cohorts (in my case University) by creating local plugin which adds tables to database field. Thank you all for your help.

SugarCRM fetching data from outside REST service to subpanel

I'm trying to create subpanel in Account detail view where list of elements is fetched from external REST service.
I know how to define subpanel, but have no idea how to fill it with data from external network source. Was trying to use get_subpanel_data but there I can only change SQL.
Any ideas how can I do this?
When I've done this in the the past, at least with Sugar 6, I opted distinctly not to try to create a true subpanel. The data being loaded is coming from an outside source and is loaded dynamically with the page, so why present it as if it's static data coming from Sugar? Instead, I created a custom Smarty template to use as the footer on the detail page. For such an example, you can check how it works on the Calls Edit View. I think it's the footerTpl parameter in the detailviewdefs.php or editviewdefs.php. I loaded the smarty template by creating a custom detail view for my module, so custom/modules/MyModule/views/view.detail.php - extend the base Detail View class and override the display to feed Smarty new params, then your Smarty template only needs to iterate through and present the data that your view defined.
To be super-hip and abide by MVC, you could even put your custom code into your bean (if it's a custom module) or into a custom controller method, then reference that from the view.detail.php, and still feed it from there to the Smarty template.
Alternatively, you could just load JavaScript into the Smarty template and use the JavaScript to call the third-party service, parse and present it, etc.
I realize this question is a little bit old now however it comes up fairly often so why not provide an answer with a couple possible solutions. I won't get into code but more just into the design theory of how it can work. If someone needs more specific code help then that is another question.
A couple ideas...
As you mentioned you can define a custom Function which will load in Data to the SubPanel from your own SQL Query. That is one method that I just recently got to finally put to use after knowing about it for a good year and a half.
When you go this route, you are restrained to using the Columns in the SubPanel. I assume it is using the actual Metadata files to determine which Field Columns a SubPanel can use so you pretty much need your custom data in a Database table to have the same column names as the fields defined in the SubPanel Metadata.
Obviously this works great in the right situation, however not always and that leads us into the 2nd method I know of.
The other way is pretty much what #Mattew-Poer mentioned in his answer. It means abandoning the SubPanel altogether and instead generating your own HTML. This is by far my favorite and prefered way of doing it and I have been some really custom modules due to this being possible in a custom module! I will show an example below.
(Click HERE to View full size image)
In the screenshot, you can see in this example that I have something looking Similar to a SubPanel however it is not and is much for flexible and easy to customize.
Example, to the far left column in my fake subpanel is image checkboxes. When clicked on, an AJAX request is made to change the Task row Status.
After that, the checkbox image is updated to indicate the new Status state, the Modified DateTime is updated, the Status column has color background SPANS and is also updated with the correct text and background color when the left side checkbox is clicked.
Doing any of this with the standard SubPanels is a complete nightmare and would be difficult to do some of the stuff that you are open to do when you build your own version of a SubPanel.
With that said, I have built an identical clone of the above screenshot using SugarCRM default SubPanels! It was a nightmare. I could easily update the content and HTML in some of the columns. I even had the AJAX click checkbox image to update and do all the other updates I mentioned above. It wasn't too hard and worked fairly good but it had some issues.
When you do inline edit, inline create record, or subpanel paging to load different set of record. You would then lose all the custom HTML formatting that was applied. The reason is, in the SubPanel you are limited to using the After UI load logic hook. So since the "Page" is loaded already, when an AJAX request is made to add/edit the subpanel content or load a new set of items with the paging links. It only loads the SubPanel content on those events and the whole Page content does not reload. Because the logic hook only fires off 1 time after the page loads, this newly loaded subpanel data doe not receive any of your custom HTML formatting.
In my case, this means that nice looking colored background Status spans are lost, the image checkboxes are lost, and some other functionality is lost.
Now to get super technical, I could have gone another 3rd route and instead made new Custom Field Types for each SubPanel filed that I needed to apply custom HTML to. This process is super hard in my experience and in some cases it really isn't the BEST solution.
Because of the reason explained, this is why my new modules use the Custom HTML route to generate my own version of a custom subpanel or whatever Data is needed in my Module pages! So far it is working better than I imagined and has opened doors for me to build custom SugarCRM modules that I previously didn't even realize would be possible to build due to some of the issues I mentioned above. Now I bypass them altogether and open the door to do pretty much anything!
I've got some really cool stuff for SugarCRM in the works right now. If anyone has any questions feel free to ask in a new question or for me personally in a comment here.