Forum

Thread tagged as: Question, Add-on-development, Members

Adding fields to back end

Hi guys,

I'm looking to add a couple of fields to the admin area of the Members app - ideally, it'd be a new form.

At the moment, I've added the fields in (Club Name, Sports, Description), but they're not auto-populating with info from the DB in the same way as the standard $Template form does (First Name, Last Name etc.).

Also, on submitting, it clears the First Name and Last Name columns from the DB.

Any ideas?

Thanks, Harry

Harry Ray

Harry Ray 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you adding these fields to the member.html template?

Nope, I'm adding them basically by replicating (or trying to) the way that the $Template variable gets set in members.edit.pre.php :

$Template   = $API->get('Template');
$Template->set('members/member.html', 'members', $Members->default_fields);

$TemplateClub   = $API->get('Template');
$TemplateClub->set('members/member.html', 'members', $Members->club_fields);
Drew McLellan

Drew McLellan 2638 points
Perch Support

That's not something that is supported, so I can't help you.

Hi Drew,

No worries - if I was to add them through the member.html template, would that be something that is supported?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, that's how it's designed to work.

Great - so just add the fields into the member.html template and it'll pull through and update as expected?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Yes that's how everything in Perch works, you should never have to touch Perch Core code or App Code. The reason we can't support that is that we then have no idea what you have done, so if you have been changing that code I would suggest starting with a clean copy of the App then modifying your templates as is described in the documentation.

https://docs.grabaperch.com/addons/members/template-tags/

Hi both,

Thanks for the help - I've undone all changes made and added those fields into the member.html template.

Now that they're in there, though, there's another issue - they don't pull information through from the DB, nor do they feed it back in on submission. They're just blank inputs at the moment.

How do we sync those fields up to the Database?

Thanks, Harry

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Please post your template and Diagnostic Report.

Diagnostic Report:


Perch information Perch: 2.8.25 Production mode: Production (100) Installed apps: content (2.8.25), assets (2.8.25), categories (2.8.25), perch_blog (5.0), perch_forms (1.8.3), perch_members (1.4.2), perch_twitter (3.5.1) DB driver: PDO DB tables: perch2_blog_authors (1), perch2_blog_comments (0), perch2_blog_index (69), perch2_blog_posts (3), perch2_blog_posts_to_tags (0), perch2_blog_sections (1), perch2_blog_tags (0), perch2_blogs (1), perch2_categories (0), perch2_category_counts (0), perch2_category_sets (1), perch2_content_index (677), perch2_content_items (91), perch2_content_regions (88), perch2_forms (0), perch2_forms_responses (0), perch2_members (3), perch2_members_forms (1), perch2_members_member_tags (0), perch2_members_sessions (2), perch2_members_tags (0), perch2_navigation (4), perch2_navigation_pages (40), perch2_page_templates (10), perch2_pages (36), perch2_resource_log (129), perch2_resource_tags (0), perch2_resources (15), perch2_resources_to_tags (0), perch2_settings (25), perch2_twitter_scheduled_tweets (0), perch2_twitter_settings (1), perch2_twitter_tweets (398), perch2_user_passwords (0), perch2_user_privileges (38), perch2_user_role_privileges (16), perch2_user_roles (2), perch2_users (2) Users: 2 App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_members', 'perch_twitter', 'perch_forms' ); Scheduled tasks for perch_blog: delete_spam_comments (1440 mins) Scheduled tasks for perch_twitter: post_tweets (1 mins), update_tweets (30 mins) Editor plug-ins: markitup H1: b919ed60f474a028cb34fa92d00f85a8 L1: decc131a5977ddd7a8d783c56351db03 F1: dc1fef2ad0fcd9f943c02ebb43d85dbc headerColour: #ffffff content_singlePageEdit: 1 helpURL: siteURL: / hideBranding: 0 content_collapseList: 1 lang: en-gb update_2.8.25: done latest_version: 2.8.15 on_sale_version: 2.8.28 headerScheme: light perch_blog_site_name: perch_blog_post_url: /news/{postSlug} perch_blog_akismet_key: perch_blog_max_spam_days: 0 dashboard: 0 hide_pwd_reset: 0 content_hideNonEditableRegions: 0 content_frontend_edit: 0 perch_blog_comment_notify: 0 perch_blog_update: 5.0.1 perch_members_update: 1.4 perch_twitter_update: 3.5 perch_members_login_page: /members/login.php?r={returnURL} perch_blog_slug_format: {postTitle}-{postID} PERCH_DEVELOPMENT: 10 PERCH_STAGING: 50 PERCH_PRODUCTION: 100 PERCH_DB_USERNAME: activeglos_user PERCH_DB_SERVER: localhost PERCH_DB_DATABASE: admin_activeglos PERCH_DB_PREFIX: perch2_ PERCH_TZ: UTC PERCH_EMAIL_FROM: jamesh@thirdfloordesign.co.uk PERCH_EMAIL_FROM_NAME: Active Gloucestershire PERCH_LOGINPATH: /cms PERCH_PATH: /var/www/vhosts/thirdfloordigital.net/ag.thirdfloordigital.net/cms PERCH_CORE: /var/www/vhosts/thirdfloordigital.net/ag.thirdfloordigital.net/cms/core PERCH_RESFILEPATH: /var/www/vhosts/thirdfloordigital.net/ag.thirdfloordigital.net/cms/resources PERCH_RESPATH: /cms/resources PERCH_HTML5: 1 PERCH_RUNWAY: PERCH_ERROR_MODE: DIE PERCH_DATE_LONG: %d %B %Y PERCH_DATE_SHORT: %d %b %Y PERCH_TIME_SHORT: %H:%M PERCH_TIME_LONG: %H:%M:%S PERCH_RUNWAY_ROUTED: PERCH_STRONG_PASSWORDS: PERCH_DEBUG: PERCH_PREVIEW_ARG: preview PERCH_TEMPLATE_PATH: /var/www/vhosts/thirdfloordigital.net/ag.thirdfloordigital.net/cms/templates PERCH_DEFAULT_DOC: index.php PERCH_DEFAULT_EXT: .php PERCH_PRODUCTION_MODE: 100 PERCH_RWD: PERCH_HTML_ENTITIES: PERCH_SSL: PERCH_STRIPSLASHES: PERCH_PROGRESSIVE_FLUSH: 1 PERCH_AUTH_PLUGIN: PERCH_DB_CHARSET: utf8 PERCH_DB_PORT: PERCH_DB_SOCKET: PERCH_SESSION_TIMEOUT_MINS: 20 PERCH_APPS_EDITOR_PLUGIN: markitup PERCH_APPS_EDITOR_MARKUP_LANGUAGE: textile Hosting settings PHP: 5.4.13 Zend: 2.4.0 OS: Linux SAPI: cgi-fcgi Safe mode: not detected MySQL client: 5.5.30 MySQL server: 5.5.30 Free disk space: 9.45 GB Extensions: Core, date, ereg, libxml, openssl, pcre, zlib, bz2, calendar, ctype, hash, filter, ftp, gettext, gmp, SPL, iconv, pcntl, readline, Reflection, session, standard, shmop, SimpleXML, sockets, mbstring, tokenizer, xml, cgi-fcgi, curl, dom, fileinfo, gd, imagick, imap, json, ldap, exif, mcrypt, mysql, mysqli, odbc, PDO, pdo_mysql, PDO_ODBC, pdo_sqlite, Phar, snmp, sqlite3, wddx, xmlreader, xmlrpc, xmlwriter, xsl, zip, mhash, ionCube Loader GD: Yes ImageMagick: Yes PHP max upload size: 128M PHP max form post size: 8M PHP memory limit: 128M Total max uploadable file size: 8M Resource folder writeable: Yes Session timeout: 24 minutes Native JSON: Yes Filter functions: Yes Transliteration functions: No PATH: /sbin:/usr/sbin:/bin:/usr/bin PP_CUSTOM_PHP_INI: /var/www/vhosts/system/ag.thirdfloordigital.net/etc/php.ini PP_CUSTOM_PHP_CGI_INDEX: fastcgi SCRIPT_NAME: /cms/core/settings/diagnostics/index.php REQUEST_URI: /cms/core/settings/diagnostics/?extended QUERY_STRING: extended REQUEST_METHOD: GET SERVER_PROTOCOL: HTTP/1.0 GATEWAY_INTERFACE: CGI/1.1 REMOTE_PORT: 59406 SCRIPT_FILENAME: /var/www/vhosts/thirdfloordigital.net/ag.thirdfloordigital.net/cms/core/settings/diagnostics/index.php SERVER_ADMIN: jamesh@thirdfloordesign.co.uk DOCUMENT_ROOT: /var/www/vhosts/thirdfloordigital.net/ag.thirdfloordigital.net REMOTE_ADDR: 82.35.54.156 SERVER_PORT: 80 SERVER_ADDR: 205.186.165.244 SERVER_NAME: ag.thirdfloordigital.net SERVER_SOFTWARE: Apache SERVER_SIGNATURE: <address>Apache Server at ag.thirdfloordigital.net Port 80</address> HTTP_COOKIE: cmsa=1; p_m=63fb36ac9baf2217a5e3c50691f5b8c9e5c1ea73; PHPSESSID=kh5fiq5iq8qmf89c6rfs0ie033 HTTP_REFERER: https://ag.thirdfloordigital.net/cms/core/settings/diagnostics/ HTTP_ACCEPT_ENCODING: gzip, deflate HTTP_ACCEPT_LANGUAGE: en-GB,en;q=0.5 HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:45.0) Gecko/20100101 Firefox/45.0 HTTP_CONNECTION: close HTTP_X_ACCEL_INTERNAL: /internal-nginx-static-location HTTP_X_FORWARDED_FOR: 82.35.54.156 HTTP_X_REAL_IP: 82.35.54.156 HTTP_HOST: ag.thirdfloordigital.net UNIQUE_ID: VwZKcM26pfQAAElCti8AAAAC FCGI_ROLE: RESPONDER PHP_SELF: /cms/core/settings/diagnostics/index.php REQUEST_TIME_FLOAT: 1460030064.6937 REQUEST_TIME: 1460030064

member.html template:

<perch:members type="text" id="first_name" label="First name" listing="true" order="1" />
<perch:members type="text" id="last_name" label="Last name" listing="true" order="2" />
<perch:members type="text" id="clubactivityname" label="Club Name" listing="true" order="101" />
<perch:members type="text" id="sports" label="Sports" listing="true" order="102" />
<perch:members type="textarea" id="description" label="Club Description" listing="true" order="103" />