Sradesign Posted April 12, 2016 Posted April 12, 2016 Hi I have another problem like always I want to have a repetitive field for each user for example we call that field (MT) each user may have numbers of (MT) with different values in his account like: Name: client number 1 MT1: 1213 MT2: 1214 Name: client number 2 MT1: 1216 MT2: 1217 MT3:1218 Name: client number 3 MT1: 1216 how to setup this scenario and how to add this MT's to user accounts like. and also how to get them in a loop.
LostKobrakai Posted April 12, 2016 Posted April 12, 2016 If you're talking about the frontend I can suggest talking a look at this: http://adamwathan.me/2016/04/06/cleaning-up-form-input-with-transpose/ In the backend you'll probably use repeaters or pagetables (FieldtypeMultiplier would work, too, for a single repeatable field). 1
Sradesign Posted April 14, 2016 Author Posted April 14, 2016 I have problem now with reading the data from repeater. see the below image my repeater have one entity now. but when I try to read it like this : <table width="100%" id="registrations" class="table table-hover table-light dataTable dtr-inline" role="grid" aria-describedby="registrations_info" style="width: 100%;"> <thead> <tr> <th>VF-ID</th> <th>Name</th> <th>Family</th> <th>Country</th> <th>Phone</th> <th>MT4</th> <th>Action</th> </tr> </thead> <tbody> <?php $registrations = $users->find("include=hidden,roles=member"); foreach($registrations as $register){ ?> <tr> <td><?php echo '<span class="badge badge-danger bg-blue btn-block">VF-' . $register->id . '</span>'; ?></td> <td><?php echo $register->fname; ?></td> <td><?php echo $register->lname; ?></td> <td><?php echo $register->country_of_citizenship; ?></td> <td><?php echo $register->phone; ?></td> <td> <?php foreach($register->mt4 as $mt4) { echo $mt4->platform; } ?> </td> <td><?php echo '<a href="/user-details/id/'.$register->id.'" class="badge badge-danger bg-blue btn-block">Edit</a>'; ?></td> </tr> <?php } ?> </tbody> </table> it shows nothing How can I access my repeater data it changed the name of nested fields by itself.
Sradesign Posted April 15, 2016 Author Posted April 15, 2016 Any thought guys ? I'm kinda stuck in this.
LostKobrakai Posted April 15, 2016 Posted April 15, 2016 It does look like it should work. What does "$register->mt4->count()" return?
Sradesign Posted April 15, 2016 Author Posted April 15, 2016 it shows 0 But as you can see the last guy have 2 MT4.
LostKobrakai Posted April 15, 2016 Posted April 15, 2016 Does $pages->get(1227)->platform work? It seems like the repeater field doesn't correctly load it's content/pages.
LostKobrakai Posted April 15, 2016 Posted April 15, 2016 The last thing to try would be if theres a difference between $page->getFormatted('mt4') and $page->getUnformatted('mt4').
Sradesign Posted April 15, 2016 Author Posted April 15, 2016 echo $page->getFormatted('mt4'); echo $page->getUnformatted('mt4'); doesn't show anything.
LostKobrakai Posted April 15, 2016 Posted April 15, 2016 You'd need to use var_dump() to actually see what's returned.
Sradesign Posted April 15, 2016 Author Posted April 15, 2016 I do this : var_dump($page->getFormatted('mt4')); echo "<hr>"; var_dump($page->getUnformatted('mt4')); and it shows NULL for both.
LostKobrakai Posted April 15, 2016 Posted April 15, 2016 Ah, did you really do $page? In your case the page seems to be $register.
Sradesign Posted April 15, 2016 Author Posted April 15, 2016 I did try with $register like this: var_dump($register->getFormatted('mt4')); echo "<hr>"; var_dump($register->getUnformatted('mt4')); and even like this: var_dump($users->get(1213)->getFormatted('mt4')); echo "<hr>"; var_dump($users->get(1213)->getUnformatted('mt4')); both gives me thousand of line which is impossible to check.mind you I have 53 field in each user page.
LostKobrakai Posted April 15, 2016 Posted April 15, 2016 I'm mostly interested in the class (get_class() will make it shorter) and if it's a PageArray in the ->count(). Also $register is sufficient.
Sradesign Posted April 15, 2016 Author Posted April 15, 2016 this will return RepeaterPageArray echo get_class($register->getFormatted(mt4)); echo "<hr>"; echo get_class($register->getUnformatted(mt4)); and this one nothing : echo get_class($register->getFormatted(mt4)->count()); echo "<hr>"; echo get_class($register->getUnformatted(mt4)->count());
LostKobrakai Posted April 15, 2016 Posted April 15, 2016 Ok, so it seems really like the repeater does just not pick up it's pages for whatever reason. For the record, which pw version are you using? 1
Sradesign Posted April 18, 2016 Author Posted April 18, 2016 any thoughts how I can fix the problem ?
tpr Posted April 18, 2016 Posted April 18, 2016 What if you use include=all, or check role set to false (sorry, on mobile, don't know the correct term for the latter)
Sradesign Posted April 19, 2016 Author Posted April 19, 2016 I still got the problem with repeaters can anyone help in that or I should go with pagefield which make my job harder to create the pages each time then import them to my user details pagefield. that's a bit ugly
LostKobrakai Posted April 19, 2016 Posted April 19, 2016 I'd look on github and the forums if other do also have issues with repeaters in the user template. There are some foggy memories, that there might have been others, but I've not much time to look myself right now.
Sradesign Posted April 19, 2016 Author Posted April 19, 2016 I can see one inconsistency between my repeaters and what rayan always shows in the pictures this is rayan's one and in my case is like the below I mean the title of fields are with id and added _repeater I don't know if that make any difference or not but why is different.
LostKobrakai Posted April 19, 2016 Posted April 19, 2016 That's what happens if there are no labels supplied. If you have labels, than this might be correlated to the overall issue.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now